Customizing the WordPress Menu with Custom Classes

The standard menu in WordPress, while powerful and easy to add onto almost any theme, leaves a bit to be desired when it comes to styling.

Not to mention, the built-in WordPress menu classes can be quite confusing. There’s menu-item-type-taxonomy, current-menu-parent, current-menu-ancestor, and a whole bunch of other confusion selectors you can choose from to make styling your menu about as fun as pulling out your hair.

A standard WordPress menu looks like this:

Gray bar with a darker gray hover. Not too much to look at right?

Just to put a simple red background hover would require you to know a few CSS selectors, and their names are quite long.

But, thankfully, WordPress also gives you the functionality to add custom classes to your menus – which makes styling them a much easier process.

So, rather than using your browser developer tools to target some baked-in, almost nonsensical menu name, you can create your own menu classes that are much easier to remember and alot easier to style.

Turn on Custom Classes in the WordPress Menu Admin

To use custom classes they have to be shown. You do this in your menu admin area.

Make sure to select the “CSS CLASSES” item in screen options and then return to your menu. You’ll notice a new box has been added to your menu items.

You can enter any name into this box. You don’t want to use any selectors like # or . (period). Just enter the class text like shown in the image below.

I’ve chosen the class name redback which is easy to remember.

After the menu is saved you can enter custom CSS anywhere you would normally do that – either in your style.css file or in a custom css plugin.

Here, I’ve chosen the following CSS rule:

1
.redback a:hover{background:red;}

That targets any item tagged with custom class redback and changes its hover state to use a red background.

You can even use the custom classes to add logos to your menu items like this:

The same principles follow with the custom classes. For more information on adding logos to your menus, checkout these two articles:

WordPress Custom Menu Items

WordPress Menu CSS

More articles about WordPress Menus:

Featured Plugin - WordPress Ecommerce Shopping Cart Plugin

Out of all the WordPress ecommerce plugins available, MarketPress has got to be the winner - easy to configure, powerful functionality, multiple gateways and more. A simply brilliant plugin!
Find out more

Featured Plugin - WordPress Facebook Plugin

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more

Featured Plugin - WordPress Q&A Site Plugin

It's now incredibly easy to start your own Q&A site using nothing more than WordPress - The Q&A plugin simply and brilliantly transforms any site, or page, into a perfect support or Q&A environment.
Find out more

Featured Plugin - WordPress Google Maps Plugin

Simply insert google maps into posts, sidebars and pages - show directions, streetview, provide image overlays and do it all from a simple button and comprehensive widget.
Find out more

Featured Plugin - WordPress Appointments Plugin

Take, set and manage appointments and client bookings without having to leave WordPress. Appointments+ makes it easy.
Find out more

Featured Plugin - WordPress Wiki Plugin

To get a wiki up and running you used to need to install Mediawiki and toil away for days configuring it... not any more! This plugin gives you *all* the functionality you want from a wiki, in WordPress!!!
Find out more

Featured Plugin - WordPress Membership Site Plugin

If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more

Featured Plugin - WordPress Infinite SEO Plugin

Fully integrated with the SEOMoz API, complete with automatic links, sitemaps and SEO optimization of your WordPress setup - this is the only plugin you need to help you rank your site number 1 on Google - nothing else compares.
Find out more

Featured Plugin - WordPress Pop-Up Chat Plugin

No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more

Comments (3)

    • Great use of that Jim.
      I’ll be doing a detailed walk through this coming week of the marketpress plugin – setting up an ecommerce site.
      Then after that, we’ll be tying that in with membership as well.
      The goal is to launch a fully-functional member/e-commerce site, and you can do it all with the WPMUDEV plugins. It’s gonna be a good show.
      of course, if you need help with your site when you get that membership plugin installed – we’re always around.
      Good luck!

Participate