• <div class="example">
    <h1>Menu</h1>
    <ul>
        <li>sub-menu</li>
        <li>sub-menu</li>
        <li>sub-menu</li>
    </ul>
    </div><!-- end of example -->
    
    <div class="example>
    <h1>Menu</h1>
    <ul>
        <li>sub-menu</li>
        <li>sub-menu</li>
        <li>sub-menu</li>
    </ul>
    </div><!-- end of example -->

    I’m trying to make a menu with wp_nav_menu() and I want to achieve a clean code like this. I’m trying to do it with a custom walker but I don’t have experience with this. I think I have to overwrite a class but …

    My idea is using h1 tags to menu items and and unordered list to submenu items.

    Coud you help me with the code?? Thanks for all

Viewing 4 replies - 31 through 34 (of 34 total)
  • Yup, nothing wrong with your two cents. But in this case, with not too large string to work with, and simply just getting rid of the classes and ID’s, my way should be a proper way.

    Hi, new here. But I saw there was talk about “add a custom CSS class to an LI item”
    The best way to do this would be a jQuery selector.css at page load, in my opinion.

    By the way.. in Norway we have a saying about “the shoes of the shoemaker’s children”. And the response utilities here could be better… can I say this ? ref https://www.bloghog.no

    Me myself would rather be avoiding too much use of jQuery for what can be done server side. And adding css class to the menu is way simpler than using jQuery by using filter:

    add_filter( 'nav_menu_css_class', 'filter_nav_menu_css_class', 10, 2 );
    function filter_nav_menu_css_class( $classes, $item ) {
    /* Do something here */
    }
Viewing 4 replies - 31 through 34 (of 34 total)
  • The topic ‘Customized wp_nav_menu()’ is closed to new replies.