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


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.

    • Elliot

    • October 11, 2013 at 1:36 pm

    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 );



  • 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“)

    • Elliot

    • October 16, 2013 at 2:21 pm

    Hi @herrfischer

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


Viewing 5 posts - 1 through 5 (of 5 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.