Highlighting current page
-
Hi. Before I start, I am not using the listpages functionality which I know allows easy page highlighting.
In a sidebar, I am displaying the child pages of a parent page. The parent page title is also a link. However, when you are on that page, it is not highlighted like the others. I’ll show the code I’m using and maybe someone can help me. Thanks
<?php if($post->post_parent) { $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); $titlenamer = get_the_title($post->post_parent); } else { $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); $titlenamer = get_the_title($post->ID); } if ($children) { ?> <div class="subNav"> <h2>More pages…</h2> <?php $parent_title = get_the_title($post->post_parent);?> <h3><a href="<?php echo get_permalink($post->post_parent) ?>">Introduction</a></h3> <ul> <?php echo $children; ?> </ul> </div> <?php } ?>so it’s the <h3>Introduction</h3> that needs to highlight if I’m on that page. I need to add a class or an ID, whatever.
The topic ‘Highlighting current page’ is closed to new replies.