Conditional statements in header
-
Hi,
I’m trying to put a conditional statement in my header that checks to see if the current page is within a certain category and then assigns a class=”current” to a link in my menu.
The menu is a static menu – i.e. not dynamically generated within a loop – so I need to call the in_category() tag from outside the loop.
Here’s where I’ve got to – I’ve only done one example
<li>
– but it’s not working:<li><a <?php if ( have_posts() ) { the_post(); rewind_posts(); } if ( in_category(11) ){echo 'class="current';} ?> href="about/accountants-for-life/">About Us</a></li> <li><a href="business-building/business-advisory-services/">Business Building</a></li> <li><a href="true-tax-efficiency/tax-advisory-services/">True Tax Efficiency</a></li> <li><a href="fixed-fee-accounting/">Fixed Fee Accounting</a></li> <li><a href="news-views/">News & Views</a></li> <li><a href="client-resources/">Client Resources</a></li>
Perhaps I’m just going about this all wrong? I’d REALLY appreciate any help with this.
Dan
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Conditional statements in header’ is closed to new replies.