[wp-hackers] Top level current page navigation

Dan Gayle dangayle at gmail.com
Mon Dec 1 19:20:27 GMT 2008


RIght now I am running a convoluted method of determining current page  
navigation for a client's blog that has thousands of posts and  
hundreds of pages:

EXAMPLE NAVIGATION TAB

<li><a href="<?php echo get_category_link(511);?>"<?php if (! 
is_front_page() && in_category('511') && !is_page('1705')) {echo  
'id="current" ';} ?>>News</a></li>


The standard solution is to have is_category, but that only works on  
the category page itself, not any children of that category. The  
in_category solution was supposed to fix that if they add the top  
level parent category to every post. The !is_page('1705') refers to an  
archive page that lists all posts, so I wanted it excluded, as well as  
the home page, both of which would be highlighted as well since they  
contain posts in the other navigation categories.

But now the writers and content managers insist on _not_ tagging posts  
with the parent category, which breaks my navigation again.

What I need is to have the top level navigation be highlighted as  
current for a specific category and any/all of its children.



More information about the wp-hackers mailing list