Support » Themes and Templates » Display SubHeader if in Certain Category

  • Resolved kennethwatt


    Hi guys
    I have the following code in a post. I want to have it so that there is the header (which contains the links to Technology and Entertainment).
    If the post is in Technology, I wish for there to be a subheader which contains a list of all sub categorys in Technology, and similarly in Entertainment.)
    I have the following code:

    <?php if (is_category('Technology')) { ?>
    <div id="subheader">This is the technology sub header.</div>
    <?php } elseif (is_category('Entertainment')) { ?>
    <div id="subheader">This is the entertainment sub header.</div>
    <?php } else { ?>
    <div id="subheader">This post aint got no category.</div>
    <?php } ?>

    In a post in the Entertainment category just shows “this post ain’t got no category”, which is the else one, as does a post in Technology. It doesn’t change if the post is ONLY in Technology and in no other one.

    Many thanks

    Kenneth Watt

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display SubHeader if in Certain Category’ is closed to new replies.