Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add the ability to insert Custom CSS Classes to menu items. I believe I do this by extending the walker_nav_menu but I'm not sure how to call the custom classes.

This seems like such a simple question but I've googled and searched here and couldn't find anything for simply adding the custom classes.

Right now I just have:

<?php wp_nav_menu( array( 'theme_location' => 'top-menu', 'walker' => new future_walker_class() ) ); ?>

and

class future_walker_class extends Walker_Nav_Menu {
/*not sure what to put here*/
}

P.S. I'm fairly new to PHP/Wordpress. I tried to be as thorough as possible so I don't waste your time.

share|improve this question
    
Can you please let us know exactly what is the need of adding custom css classes and do you need to add the same class to each menu items ? or do you want different classes based on any condition to menu item, sub menu items etc ? –  Subharanjan Jan 17 at 6:46
    
I'd like to give the menu item an icon from an image sprite using css. So the classes need to be different (based on input from the Menu admin panel). –  Derek Jan 17 at 6:49
    
I know it automatically generates one like .item804 but in case I move them around (and there's quite a few of them) I want the css code to be easy to read and edit if needed. –  Derek Jan 17 at 6:51

1 Answer 1

If its a matter of adding icons as per the classes, add it from the back-end and use that class to assign icons through css.

enter image description here

share|improve this answer
    
Yep I've done just that. But the custom class doesn't print to html. So I figured that I had to call it somehow using the walker class. –  Derek Jan 17 at 7:11
    
Do you have any code that renders the menu structure ? or Can you tell me the name of the Theme you are using ? –  Subharanjan Jan 17 at 7:14
    
Sorry for delay... I tried doing some digging myself. I rephrased the question with more info that I got from my digging: new question –  Derek Jan 18 at 6:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.