My sidebar loops through all of the child pages based on the parent page. For example, if you’re in the “About” section you’ll only see “About” child pages in the sidebar.
My problem is that I have no way of highlighting the current page. For example, if you’re on the child page “Our Team” (under “About”) I’d like to give the sidebar “Our Team” a tag link a “current-page” class.
Is there a way to add a “current-page” class dynamically to the child page you’re on?
<?php
if ( $post->post_parent == '4' ) {
query_posts("post_type=page&post_parent=4&orderby=menu_order&order=asc");
} elseif ( $post->post_parent == '6' ) {
query_posts("post_type=page&post_parent=6&orderby=menu_order&order=asc");
} elseif ( $post->post_parent == '8' ) {
query_posts("post_type=page&post_parent=8&orderby=menu_order&order=asc");
} elseif ( $post->post_parent == '10' ) {
query_posts("post_type=page&post_parent=10&orderby=menu_order&order=asc");
}
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
...
I see that you are have a hard time on this so here:
and at the end of your loop add
no after that i would like to say that you really should use WP_Query instead of query_posts any time that its not the main query in the page.
and when I’ll get back I will post and example using wp_list_pages()