WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. chuubenettes
    Member
    Posted 4 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic