Styling the current_page_item tag for child pages in WordPress

During a recent WordPress theme build, I wanted to have a sidebar that permanently showed child pages with a hover state and an active state utilising the current_page_item tag as generated by WordPress.

The sidebar menu in it's plain state with no hovers or active states

So far so good, but during testing, when I clicked on a parent page, all the child pages inherited the current_page_item css styling thus:

The same menu when you click on the 'meet the team' link - the child pages all inherit the current_page_item styling

…which is not pretty! So after some css thrashing which did nothing, I caved in and Googled it. Found a solution pretty swiftly on the ever-increasingly-useful WordPress support forum (which I shall make my first stop in the future!) from a user called SurfHost who posted the following solution:

.menu .current_page_item a, .menu .current_page_item a:visited {
	font-weight:bold;
}

.menu .page_item ul li a, .menu .page_item ul li a:visited {
	font-weight:normal;
}

.menu .page_item .current_page_item a, .menu .page_item .current_page_item a:visited {
	font-weight:bold;
}

Which, with some adjusting to my own div id’s worked perfectly:

The menu with the updated styling - child items have their own styling

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

Being

I'm a Bournemouth-based Freelance Graphic and Web Designer with six years industry and more than eleven years personal experience in all aspects of digital design and new media.

 

I have a broad range of experience covering web design (custom cms theme design for Joomla, Wordpress & Drupal), design for print (letterheads, business cards, logos etc) and new media (banner ads, flash animation, interactive info portals). I believe that a design is only as good as it is usable, and prioritise the latest accessibility standards in all my online work.

 

Toby James Pestridge

Toby James Creative

14 Twyford Close

Bournemouth, Dorset, BH8 0PQ UK

01202 565595


Download hCard

Tweeting

  • Say hello to the Fail Whale!
 

© 2010 Toby James Creative All Rights Reserved | Powered by Wordpress, built by me

 

Find us on the FreeIndex directory under Web Design Resources | Design Directory UK | Business Directory - Directory of UK companies and businesses, arranged by category.