WordPress.org

Support

Support » How-To and Troubleshooting » How do I hardcode: show gallery only if > 1 image. else show single image

How do I hardcode: show gallery only if > 1 image. else show single image

  • chuubenettes

    @chuubenettes

    Hi there,

    I’m hardcoding the gallery shortcode into my wordpress theme template so that I can have a predetermined place where all images will show up in a blog entry. However, if there’s only 1 image, I don’t want to show a gallery.. I’d just like to show the single image.

    Need help though to write a code that says:
    if image count > 1, use gallery shortcode:

    <?php
        $gallery_shortcode = '[gallery]';
        print apply_filters( 'the_content', $gallery_shortcode );
     ?>

    else if image count is 1, show single image.

    I’d really really appreciate any guidance on how to do this. thanks so much!

  • The topic ‘How do I hardcode: show gallery only if > 1 image. else show single image’ is closed to new replies.
Skip to toolbar