Customizing Behavior of current_page_ancestor CSS tag
-
I use wp_list_pages() to generate the menu in my header.
This works for all pages and subpages as I can use the current_page_item and current_page_ancestor tags to keep the top-level section highlighted as the user navigates around sub-pages.
But here’s the issue: I have a top-level page called “Authors” which uses a custom page template to loop through all the authors in the WP installation. It links to the Author page (author.php) when a user clicks on a specific author. So when the user goes to my custom top-level “Authors” page, the “Authors” page in the menu gets the “current_page_item” CSS tag, so I can style it correctly.
However, when the user clicks on an author and gets sent to the “author.php” page, the “Authors” section in the menu is no longer highlighted.
How can I correct this behavior short of overriding the wp_list_pages function and reg-ex’ing the output? My current thoughts:
- I could try to fool WP into thinking that I’m still on the Authors page when I’m really on a specific author.php page so that it would give me the correct tags whenever I’m in author.php.
- I could embed some CSS to the author.php page to re-style the Authors tab by addressing a specific page-id tag in the menu.
I’m not sure how to do #1, and #2 is just too ugly.
Any thoughts? Thanks in advance.
Jeff
- The topic ‘Customizing Behavior of current_page_ancestor CSS tag’ is closed to new replies.