Problem with conditional tags
-
Hello
I am using the following conditional tags to output a current class for a ‘News’ tab in my websites’ menu:
<li<?php if ( have_posts() ) { the_post(); rewind_posts(); } if ( is_home('') || is_page('') || is_category('3') || is_category('266') || is_category('267') || is_category('278') || is_category('316') || is_category('317') || is_category('318') || is_category('319') || is_category('448') || is_category('449') || is_category('507') || in_category('3') || in_category('266') || in_category('267') || in_category('278') || in_category('316') || in_category('317') || in_category('318') || in_category('319') || in_category('448') || in_category('449') || in_category('507') ) { } else { echo ' class="current"'; } ?>><a href="https://www.mysite.com/news">News</a></li>
The code is meant to output nothing for the categories specified, as well as my site’s homepage and static pages. Otherwise, it should add the current class to the
<li>
tag.However, when viewing a certain category (with an ID of 449), the code doesn’t work, meaning the tab doesn’t highlight.
I have tried adding an elseif statement to the code, however that didn’t work.
I have looked thoroughly throughout my template but cannot find any code which conflicts with it.
Can anyone help me with my problem?
- The topic ‘Problem with conditional tags’ is closed to new replies.