I need to add a class to an <ul> element on my custom navigation menu in wordpress. I have used wp\_nav\_menu() function to try to achieve this but it is not working. Any help is appreciated, thank you
In my functions.php I have added the following function
function html5blank_nav()
{
wp_nav_menu(
$args = array(
‘theme_location’ => ‘header-menu’,
‘container’ => ‘ul’,
‘container_class’ => ‘nav-menu’,
‘menu’ => ‘7’,
‘menu_class’ => ‘menu’,
‘menu_id’ => ‘nav-menu’,
)
);
}
wp_nav_menu( $args );
My menu is registered like this
function register_html5_menu()
{
register_nav_menus(array( // Using array to specify more menus if needed
‘header-menu’ => __(‘Header Menu’, ‘html5blank’), /
‘sidebar-menu’ => __(‘Sidebar Menu’, ‘html5blank’),
‘extra-menu’ => __(‘Extra Menu’, ‘html5blank’)
));
}
Out of curiosity why would you need a class on the UL ? You can target anything with parent classes and tags.
Like:
Header ul {} ;