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


Show link only if ACF image field not empty

  • 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.

    $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)?

  • When I added this code block to the post:

    $view_on_wall = get_field(‘wall_image_1’, false, false);

    I got nothing back.

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

You must be logged in to reply to this topic.