Home Forums Add-ons Gallery Field How To display only one image in front end.


How To display only one image in front end.

    • Yashi

    • October 21, 2013 at 5:31 pm

    How To display only one image in front end.

    eg: i have a photo gallery page and that have all the galleries i created. and this is a custom post. so my fields are title, content and gallery field. what i want to do is in the gallery page i want to show only title and one gallery image. if visitor click that thumbnail it goes to full gallery view page.. actually i can use featured image section to show that but i think it will be confusing my client. so i want to show only one image in that area.

    so can you help me with this… please..

    • Elliot

    • October 21, 2013 at 6:24 pm

    Hi @Yashi

    The gallery field will return an array of images, correct?
    Knowing this, you can simply interact with the first element in the array like so:

    $images = get_field...
    $image_1 = $images[0];

    Good luck.


    • Yashi

    • October 21, 2013 at 6:31 pm
    This reply has been marked as private.
    • Yashi

    • October 22, 2013 at 4:08 am

    i found the solution and i resolved it thanks…. your example work for me

    $images = get_field('gallery_bucket'); 
    $image_1 = $images[0]; 
    <img src="<?php echo $image_1['sizes']['gallery-thumb']; ?>" alt="<?php echo $image_1['alt']; ?>" />
Viewing 4 posts - 1 through 4 (of 4 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.