I have a category navigation in the wordpress sidebar which contains two main categories A and B. In these categories there are subcategories like A1, A2, …
For example when main category A is selected…
| A | B |
| --------|
| - A1 |
| - A2 |
| - A3 |
… and when B is selected:
| A | B |
|-------- |
| - B1 |
| - B2 |
| - B3 |
The problem is, that A is default (when you first visit the blog) but when a user selects an article from category B1 the postback is sent to the server and the article is displayed. But then A is selected again.
My idea was to check which post is currently displayed and switch the navigation based on this. But how can I find out which article is currently displayed when the code is in the sidebar.php and not in the wordpress loop?
Does anyone have a suggestion?
I ended up using this plugin: http://www.screenshine.net/blog/1474_wordpress-plugin-show-active-category
and then using jQuery to search for the item with the highlighted class, searched the parent div of it, checked if it’s A or B and based upon what it is I show A and hide B or show B and hide A.