I am trying to learn how to design WordPress themes, and I’m having a hard time understanding how, and what markup, WordPress generates for the main menu.
I inspected some different themes with Firebug, and it does not appear that they share the same markup for the Menu Items.
What I don’t understand, is how one can style their menu, when they do not know what markup WordPress generates?
Also, I’ve been watching WordPress theme design seminars, and the guy creates a menu in the WordPress dashboard for a main menu, while some themes I have used, don’t require that? Whats the difference?
I hope my question(s) are clear enough, if not please let me know. Thanks.
P.S: Yes, I have looked at the Codex.
There are a few ways you can create a list/menu of your WordPress pages. I think using
wp_list_pages()will show them all. Callingwp_nav_menu()without passing in a first argument will also list all the pages. If you do pass in a “theme location” as the first argument only the menu assigned to that theme location will be displayed.Check the WordPress codex for detailed information about each function.
Regarding the styling. As far as I know WP wraps each menu in a
div, then all the menu items are put inli:s inside anul. If you have hierarchies the nestedul:s will be put inside the parentli. WP also adds a BUNCH of handy (and unnecessary) classes to each li that helps you style the menu even further.I normally just style the
ulandlias they are always present in a WP menu.