Support

Account

Home Forums Add-ons Gallery Field Display number of photos in a gallery field

Solved

Display number of photos in a gallery field

  • Is there an easy way to echo out the number of images in a gallery?

    For example, I’m showing the first image of each gallery on a page, with a title and under the title I’d like it to say something like “(23 photos)” .

    Thanks for your help in advance.

  • Hi @brianyerkes

    Sure. So, the get_field function will return an array containing all the images right? Therefor, you can target the first image like so:

    
    $images = $image[0];
    

    As for the count? There is a PHP function called count which will do this for you:

    
    echo count( $images );
    

    Easy

    Thanks
    E

  • Perfect, thank you Elliot. (been using ACF for a while now, also repeater and gallery addons…and ACF (along with gravity forms) is easily one of the best coded plugin out there.

  • how to check if one image or more? (echo “1 picture” / “2 pictures“)

  • Hi @herrfischer

    This kind of PHP question is best solved on google, not ACF

    Thanks
    E

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

The topic ‘Display number of photos in a gallery field’ is closed to new replies.