What is wrong with this conditional statement?
Hi I am trying to have the navigation highlights determined by what category or page you are looking at using wordpress. Can someone tell me what is wrong with a statement like this:
<?php if (in_category('b')){ ?>
<ul>
<li><a href="#">A</a></li>
<li><a class="current" href="#">B</li>
</ul>
<?php } else { ?>
<ul>
<li><a class="current" href="#">A</a></li>
<li><a href="#">B</li>
</ul>
开发者_运维知识库<?php } ?>
I am trying to use something like this but my else statement is ignored and the 'b' is always current regardless of category.
You are either not inside a post or everything is in category 'b'.
See http://codex.wordpress.org/Function_Reference/in_category for in_category() information.
read here.
You've got to write something like:
<?php if (in_category('b')): ?>
<ul>
<li><a href="#">A</a></li>
<li><a class="current" href="#">B</li>
</ul>
...
精彩评论