Forums

[resolved] Conditional Gallery? (3 posts)

  1. mikejandreau
    Member
    Posted 2 years ago #

    Right now, I'm inserting a gallery into a post directly via the template file. However, some posts don't have galleries.

    Here's what I've got now:

    <h2>Gallery</h2>
            <?php echo do_shortcode('[gallery option1="value1"]'); ?>

    Is there any way that I can make the <h2>Gallery</h2> not show if there's no gallery?

    I searched the codex, but there doesn't appear to be any if_gallery functionality. Any thoughts?

  2. Safirul Alredha (zeo)
    Member
    Posted 2 years ago #

    Wondering whether if ( gallery_shortcode() ) works.

  3. mikejandreau
    Member
    Posted 2 years ago #

    Perfect! That worked. I just didn't know what I needed to look for in the codex. Thanks Zeo!

Topic Closed

This topic has been closed to new replies.

About this Topic