I am learning wordpress
together with bootstrap
and somehow I can’t add class
on UL
tag.
In the screenshot, I want to add class nav nav-tabs
on UL
but it was added on parent div
$defaults = array(
'menu_class'=> 'nav nav-tabs',
);
wp_nav_menu( $defaults );
Inspected element:
Referrence:
http://codex.wordpress.org/Function_Reference/wp_nav_menu
First of all, you need to create a custom navigation menu from
Appearance -> Menus
.Then, use the
wp_nav_menu
with the following parameters:There’s a lot you can read about WordPress Menus. I suggest the following:
http://codex.wordpress.org/Navigation_Menus
http://www.paulund.co.uk/how-to-register-menus-in-wordpress
You need to specify the container element, in our case
'ul'
tag, and than specify the class that we will assign in'menu_class'
. Here is the sample code:Update: this was caused by the fact that i didn’t have a menu created in the menu page.
I want to add a class to the
ul
ofwp_nav_menu
. I tried this code:According to wordpress codex changing the menu from
'menu_class' => 'menu'
, should change the class of theul
, but instead it changes the class of thediv
wrapping theul
.Sample Page
I had the same problem, so I changed the word “theme_location” to “name” and it works perfectly.
Example:
So for your code:
enter image description here
You can also put it into a container like a <DIV> or a <NAV> etc.
Example:
enter image description here
This is how you should do it, it works for me.
You can try this. It works for me