Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Can you use HTML in Wordpress Custom Menu

Does anyone know how you would go about configuring the Wordpress custom menu so that it allowed you to use custom html code within the menu selection choices.

5 Answers

Andrew McCormick
Andrew McCormick
17,730 Points

I haven't done anything with a custom Walker fucntion, but how about something like this? http://jamescollings.co.uk/blog/wordpress-custom-walker-output-section-of-menu/ If there's a specific piece of the code that doesn't seem to make sense or your not sure what it does, then you can post it and maybe we can flesh it out on here.

** even more detailed: http://code.tutsplus.com/tutorials/understanding-the-walker-class--wp-25401

Andrew McCormick
Andrew McCormick
17,730 Points

I couldn't think of a use case for this in my mind till I saw the example here and now I'm intrigued. See if this helps: http://stackoverflow.com/questions/12250866/how-to-add-custom-html-to-wp-nav-menu

out of curiosity, what do you plan on doing?

Anthony Moore
Anthony Moore
2,282 Points

Hi Derek,

You can try playing around with the arguments in the wp_nav_menu() function if you just need to change some of the markup.

http://codex.wordpress.org/Function_Reference/wp_nav_menu

If you really need to customize the menu you would need to create your own "Walker" function.

http://codex.wordpress.org/Function_Reference/wp_nav_menu#Using_a_Custom_Walker_Function

Hi Anthony & Andrew thank you both for your responses. Menus seem to be my weakness. I have never been able to find good tutorials on creating and styling more complex menus in Wordpress.

I think that you are both correct, it seems like the "Walker Function" probably the best way to do it. I was wondering, could either of you recommend any additional reading aside from the Wordpress codex that explains this in more detail and doesn't just provide the code to copy and paste. I would really like to learn how it works.

Thanks & Cheers!

Awesome, thanks Andrew!