• Resolved Jim R

    (@jim-r)


    I searched but couldn’t find a solution.

    Here is the code I’m using, taken from the WP docs:

    <?php if (is_category('429')) { ?><p>
    We realize that some of the Newsstand links are to papers which require you to subscribe to their paper as well.  They are not part of HHR.</p>
    <?php } ?>

    I have checked the category ID, and it’s accurate. That code is on single.php in my theme, so every time my user clicks on a post in that category, the above shows up.

    I know it’s the right file…well…because I’m familiar with what single.php produces within my theme. I also know it’s the right file because when I post the whole code…

    <?php if (is_category('429')) { ?><p>
    We realize that some of the Newsstand links are to papers which require you to subscribe to their paper as well.  They are not part of HHR.</p>
    <?php } elseif (is_category('Category B')) { ?>
    <p>This is the text to describe category B</p>
    <?php } else { ?>
    <p>This is some generic text to describe all other category pages,
    I could be left blank</p>
    <?php } ?>

    …it bypasses the “if” and “elseif” and just prints the “else”-> This is some generic text to describe all other category pages, I could be left blank.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Sorry – I’m not actually sure what your problem is. What happens when you try to use the code posted above?

    Thread Starter Jim R

    (@jim-r)

    Nothing happens. What I want to happen logically is:

    If I’m in a post under the category of Newsstand (id=429), print “this” at the top of the post (single.php).

    Thread Starter Jim R

    (@jim-r)

    Figured it out. It needs to be in_category. is_category checks to make sure what category archive page you’re on. in_category checks to make sure what category the post is in.

    Nice! I do love WP.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category Template…’ is closed to new replies.