Guess I found a better solution, having re-read the Conditional Tags article from the Codex. ?? I’m using it in the a tag, since putting it in the li tag doesn’t work for me:
<a if ( is_page('') && $post->post_parent ) {
echo "class=\"current\"";
} elseif (is_page('5')) {
echo "class=\"current\"";
} else {
// display nothing
}
?> href="some_link_fetching_tag_here">
If li tags works for your template, you can put this code in it:
<li if ( is_page('') && $post->post_parent ) {
echo "class=\"current\"";
} elseif (is_page('5')) {
echo "class=\"current\"";
} else {
// display nothing
}
?>>
This piece of script is obviously looking to see whether the page displaying is a subpage of a page which id you’ve specified in the line 3, and if it is it adds a special class to the link. If it is that page itself, it also adds a special class to the link. If it’s some other page, it does nothing.
The downside is that you can’t use it with a dynamic menu which is built automatically. I’m building the menu by hand, so it works okay for me. Probably there are other ways to achieve what you need.