Support

Account

Home Forums Front-end Issues show custom fields front-end – if data inside.

Solving

show custom fields front-end – if data inside.

  • How to: show custom fields front-end – if data inside.

    Challenges: only show a custom field if the “parent” custom field also is filled
    AND only show a field if data inside (simple custom field)

    What i have:
    Allots of custom fields.
    mostly, selcetion and checkboxes in the back end. That is used in woocommerce.

    What have i done:
    Google as H……. 🙂 and Been trying REALLY many diffrent types of examples.

    What do i need:
    A Way to show my custom fields front end, but only if there is data in the field.
    And WITHOUT showing blank or Line shift.

    Ex: i have field with: car manufator with all car manifactors.
    Many fields of all the cars, and they have there Owen list with all models from the manifator.”
    (Inserted manually, but not saved for alter use, as option for all product for some reason).
    Ex: Audi is is only showed if it’s also selected in the car manifactor. No matter, if it have one or more models selceted inside.
    SO:
    if Audi is selcetced in car manifactor.
    It Will also show Audi models.

    Where do i want this:
    Page/ product content

    How do i want it to be done:
    If possible!
    Like a Add_funktion or somthing. I that way im able to insert it where i want it, without having to Think on templates updates and so one.

    Thank 🙂

  • You can do that..

    <?php if( get_field('field_name') ): ?>
    	<p>My field value: <?php the_field('field_name'); ?></p>
    <?php endif; ?>

    Here is the official link
    https://www.advancedcustomfields.com/resources/hiding-empty-fields/

  • Nope 🙂
    That code only do the job, if it’s a “simple” fields.

    But my issue is, that i want to hide data from field2, <- triggeret IF = Audi, in field1, if it’s not having Audi inside field1.

    Field1 contain all car manifactor, and it’s also used for all car names that have the models inside.

    My issue is, when i have models inside (field2) it’s being showed, evne that the car name not inde field1. 😩

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘show custom fields front-end – if data inside.’ is closed to new replies.