The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Sidebar: Is it possible to get <?php if (is_single() to act like (is_category() (3 posts)

  1. edd_lasthours
    Posted 7 years ago #


    I'm working on a site where the side navigation changes depending what the category is. Easy to do with the (is_category('') tag. But I'd like the sidebar navigation to remain the same for all the single pages that are within that category. So lets say I have category '5' for features which means for the is_category it looks something like

    <?php elseif (is_category('5') ) : ?>
    <div class="headline_line"><h2><span>Feature types</span></h2></div>
    <div class="content_features_navigation">
    	<div class="current"><li><a href="#">Print features</a></li></div>
    	<li><a href="#">Radio features</a></li>
    	<li><a href="#">Video features</a></li>
    	<li><a href="#">Photo features</a></li>

    I'd like to have the same thing for all the posts that are within this category. I know I could do this by making a single5.php file, and call a sidebar-features.php sidebar (or equivalent), but this seems like a bit of a labourious work-around. Is there a way to do it with a conditional tag in the sidebar. Sorry if this is really obvious, but I've scoured http://codex.wordpress.org/Conditional_Tags and couldn't find anything.

    many thanks!

  2. esmi
    Forum Moderator
    Posted 7 years ago #

    Did you check out the in_category() conditional?

  3. edd_lasthours
    Posted 7 years ago #

    No, I hadn't realised that existed, I clearly didn't look as closely as I should have done. Problems solved!! Thanks Esmi.

Topic Closed

This topic has been closed to new replies.

About this Topic