Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The dilema:

  1. I have a category menu in sidebar.php that highlights the category one is in.
  2. I need to keep that highlight ON when one dives into a post of that category.
  3. The blogs posts are usually associated with more than one category. So we can't rely on getting the posts category to achieve this as it'll return multiple categories.
  4. Furthermore, the user is able to navigate to the next or previous post from within the post, so when the user navigates with this method, how will that communicate to the category menu that it's still in the originally specified cat?

You can see it partially working here. When you are in catagory.php, i have it so that it highlights the current category in the category menu, but it's not working once you go to a post.

I think this one is surely for the pros. I dont even think Mullenweg could figure this out!

share|improve this question
1  
The question doesn't make sense. One is not "in" a category unless they're looking at the category archive. You can't be in a category archive when looking at a single post. If you're looking at a single post, then you need to examine the post categories and highlight them all appropriately. Or just use one cat per post. –  Otto Apr 15 '11 at 18:33
    
Thats the thing, i need to highlight only the category the user came from in the previous page. And theres no way i can't put posts into only one category. The company is a studio that does direction, post and interactive, sometimes the projects straddle those fields. –  RGBK Apr 16 '11 at 20:30

1 Answer 1

1) For your sidebar menu highlighting, try using has_category( $cat ) (Codex ref) rather than in_category( $cat ). (Reference Otto's comment above.)

2) For navigation, if you're using previous_post_link()/next_post_link() (Codex ref) use the $in_same_cat argument.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.