I have a WordPress site (2.6.2) in which I have set the Home page to a static page instead of the normal posts page. The ID of this page is 2, so in the WordPress template I have changed the wp_list_pages to look like this:
<?php wp_list_pages('exclude=2&title_li=&depth=1' ); ?>
this works fine, but now the Home page doesn’t get ‘lit up’ when it’s selected (because in fact it’s page_id 2 that is selected, and it doesn’t show in the menu). Is there any easy way around this?
If not, in broad outlines, what’s the hard way around this? Make my own version of the wp_list_pages function?
Thanks!
Setting a static page as the front page doens’t highlight the menu link, which is at the heart of the question.
So, you could server-side customize (hack) the wp_list_pages function, but here’s a client-side option if you so choose:
Use the jQuery library (conveniently it comes with WP 2.2+), call:
or load your own version:
Now add a bit of javascript in your template, something like:
The a:first portion assumes the first link in your menu is the home/frontpage link. If it’s not, select via href value or position. Here’s by postion:
~~~~~~~~~~~~~~~
Example:
Caveats: