Support

Account

Home Forums ACF PRO Show link only if ACF image field not empty

Solving

Show link only if ACF image field not empty

    • minam

    • July 23, 2020 at 6:16 pm

    I am trying to show a link on a portfolio post only if there is an image in the ACF image field called ‘wall_image_1’. If no image has been set, I want to not show the link. I am using ACF PRO through the Avada theme (7.0)

    The following code is showing the link whether or not the image field ‘wall_image_1’ is blank or not.

    <?php
    $view_on_wall = get_field(‘wall_image_1’, false, false);
    if ( !empty($view_on_wall) ): ?>
    <h5>View on Wall</h5>
    <?php endif; ?>

  • Sounds like the image field isn’t empty then. What is output if you do var_dump($view_on_wall) or print_r($view_on_wall)?

    • minam

    • July 23, 2020 at 11:44 pm

    When I added this code block to the post:

    <?php
    $view_on_wall = get_field(‘wall_image_1’, false, false);
    print_r($view_on_wall);
    ?>

    I got nothing back.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.