• Hey Folks,

    I am having a problem with conditional tags. I want a special message to appear above all of the post that are in category 12. Therefore I am using the following conditional tag

    <?php if(is_category('12')){echo 'This Is Category 12';}?>

    However, this tag only works on category templates and archive templates. It does not work on single post templates. Does anyone know why? And, does anyone know how I can display a special message on single posts that are in a certain category?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am looking for the answer to this problem as well.

    What I am trying to do is say ‘if this post is in category 13, then insert the contents of this php file’.

    Specifically, I want to insert an subscription link in the header of any post that is in my podcast category, no matter where the post shows up – main index, archive, single post, etc.

    I spent 2 hours looking on the forums, and another hour trying to figure it out using google. I apologize if I’ve missed the answer somewhere. Thanks in advance for any help you brainy folks can offer.

    Hello

    Try:

    <?php if(is_single() && in_category('12')){echo 'This Is a single post filed in Category 12';}?>

    Hope it helps. 🙂

    BPartch, that absolutely helped me. I was able to modify it a little and it solved the single post part of my problem. (Thank You!)

    <?php if(is_single() && in_category('13')){include ('podcast-feed.php');}?>

    A little more fiddin’ with it and I got it to work on my main index page as well

    <?php if(in_category('13')){include ('podcast-feed.php');}?>

    My problem was that I was trying to use is_category rather than in_category

    Thank you so much for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem With Conditional Tags’ is closed to new replies.