0

I'm trying to convert HTML template to a wordpress. Now I'm trying to add a class to the elements of ul, li and in my wordpress wp_nav_menu. This is what the HTML menu looks like:

<ul class="menu">
    <li class="has-dropdown">
        <span>Home</span>
        <ul class="menu-dropdown">
            <li><a href="index-2.html">Home 01</a></li>
            <li><a href="index2.html">Home 02</a></li>
            <li><a href="index3.html">Home 03</a></li>
            <li><a href="index4.html">Home 04</a></li>
            <li><a href="index5.html">Home 05</a></li>
        </ul>
    </li>
    <li class="has-dropdown">
        <span>Our Fleet</span>
        <ul class="menu-dropdown">
            <li><a href="our-fleet-01.html">Our Fleet 01</a></li>
            <li><a href="our-fleet-02.html">Our Fleet 02</a></li>
            <li><a href="our-fleet-03.html">Our Fleet 03</a></li>
            <li><a href="our-fleet-04.html">Our Fleet 04</a></li>
            <li><a href="our-fleet-05.html">Our Fleet 05</a></li>
            <li><a href="our-fleet-single1.html">Our Fleet Single 01</a></li>
            <li><a href="our-fleet-single2.html">Our Fleet Single 02</a></li>
        </ul>
    </li>
</ul>

In header.php

<?php
wp_nav_menu(array(
    'theme_location' => 'top_menu',
    'container'  => '',
    'items_wrap'  => '<ul class="menu">%3$s</ul>',
    'items_wrap'  => '<li class="has-dropdown">%3$s</li>',
    'link_before' => '<span>',     
    'link_after'  => '</span>',
    'items_wrap'  => '<ul class="menu-dropdown">%3$s</ul>',
));
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.