0

I'm a newbie to WordPress core and development process. As I have a little knowledge of WordPress functions. But I need the help from you guys.

Actually, i'm developing my first theme and i already have the CSS for my menu. The menu has been registered in functions.php.

I've used the code posted below to add my class "mainnav-section".

<?php 
     $args = [
       'theme_location' => 'header-menu',
       'container'      => 'ul',
       'container_class'=> '',
       'menu_class'     => 'mainnav-section'
     ];
     wp_nav_menu($args);
 ?>

And it executed this.

<ul id="menu-header" class="mainnav-section">
    <li id="menu-item-511" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-511">
        <a href="http://#">Latest</a>
        <ul class="sub-menu">
            <li id="menu-item-512" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-512">
                <a href="http://#">HardFork</a>
            </li>
        </ul>
    </li>
    <li id="menu-item-513" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-513">
        <a href="http://#">Innovations</a>
    </li>
</ul>

All I want to to do is to add my CSS class to main-menu items, sub-menu and list items. Because I have the CSS and JS completed to get the desired menu.

u-ways
  • 6,136
  • 5
  • 31
  • 47
tassawarr
  • 1
  • 2

0 Answers0