How to add a class to <ul> element in WordPress navigation menu

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’)
));
}

1 Comment
  1. Out of curiosity why would you need a class on the UL ? You can target anything with parent classes and tags.
    Like:

    Header ul {} ;

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer