• How do I do to remove the class and the id from the
    li tag in the wp_nav_menu() function or at least how can I rename them so they don’t have such a long names with more than one class like the li in the following example

    <ul id="topnav">
    <li id="menu-item-4" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-4"><a href="https://mysite/">Home</a></li>
    <li id="menu-item-5" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-5"><a href="https://mysite/">Mobile</a></li>

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • I think you should be able to remove them using the ‘nav_menu_css_class’ and the ‘nav_menu_item_id’ filters. Why do you want to remove them, if you don’t mind my asking?

    Thread Starter arturex

    (@arturex)

    Thanks I’m goona look for that and let you know how it goes..

    I want to remove them because I just wan’t a clean code and don’t want classes or id’s Im not using now, but be able to put them back if I need them in the future.
    I already did remove the container and just left the ul with the id I want like this:
    <?php wp_nav_menu( array( 'theme_location' => 'top','menu_id' =>'topnav','container' =>'none','items_wrap' => '<ul id="%1$s">%3$s</ul>',)); ?>
    But now I want to see if there is a way to control the menu items.
    I’ll try your suggestion. Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove the id and class from the tags in the wp_nav_menu() function’ is closed to new replies.