Support

Account

Home Forums Front-end Issues Echo image not working.

Solved

Echo image not working.

  • Hi All,

    I have six images that I’m trying to echo out on the front end:

    <!– Advanced Custom Fields –>
    <?php $thumb_one = get_field(“thumb_one”); ?>
    <?php $thumb_two = get_field(“thumb_two”); ?>
    <?php $thumb_three = get_field(“thumb_three”); ?>
    <?php $thumb_four = get_field(“thumb_four”); ?>
    <?php $thumb_five = get_field(“thumb_five”); ?>
    <?php $thumb_five = get_field(“thumb_six”); ?>

    Images one to four display perfectly but the last two fail to load. I’ve set the thumbnails to appear in the correct location but nothing works.

  • get_field() doe not echo values. If you want to echo them then you either need to do so or you need to use the_field()

    
    // this
    <?php echo get_field('thumb_one'); ?>
    // or this
    <?php the_field('thumb_one'); ?>
    
  • You can use this plugin https://wordpress.org/plugins/acf-views/ to easily display images, with a simple shortcode (like [acf_views view-id=”x”]), that can be pasted anywhere, including page editors. Also you don’t need to take care of an image tag, the plugin will print the final markup. It also supports other field types.

  • Thank you Maxixm. Much appreciated.

  • Thanks John, sorry for long delay with my reply.

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

You must be logged in to reply to this topic.