Support » Plugins » Hacks » PHP: is_single for specific tagged single pages?

  • Resolved derekbeck

    (@derekbeck)


    Anyone know how to construct an if/then statement for single pages that have a specific tag (or alternatively, a category)?

    I want to include a php file only on the display of certain posts based on their tag (or alternatively, category).

    Thanks!
    Derek

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi

    (@esmi)

    Forum Moderator

    <?php if( in_category( '5' ) || has_tag( 'mild' ) ) :?>
    [ do stuff ]
    <?php endif;?>

    http://codex.wordpress.org/Conditional_Tag

    derekbeck

    (@derekbeck)

    Awesome, that worked great. FYI for future readers: the link above should be http://codex.wordpress.org/Conditional_Tags

    Also, I decided to go w/ category instead of tag, and here’s the final code I used:

    if ( in_category(6) && is_single() ) {
    include("my.php");
    }

    I think the is_single is redundant with the in_category, as the latter probably must be on a single page, but this way I’m sure.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP: is_single for specific tagged single pages?’ is closed to new replies.