How to customize the list of categories in WordPress

I have the following HTML and would like the output of the list of my WordPress was consistent with it. Categories without children would be within a <li> categories with children already enter into a dropdown menu. HTML and JS to all this work is perfect, but I knew not create the function to return the WordPress categories in this format.

   <ul class="nav">
        <li><a href="#">Categoria 1</a></li>
        <li><a href="#">Categoria 2</a></li>
        <li class="dropdown">
            <a data-toggle="dropdown" class="dropdown-toggle" href="#">Categoria 3<b class="caret"></b></a>
            <ul class="dropdown-menu">
                <li><a href="#">Categoria 3.1</a></li>
                <li><a href="#">Categoria 3.2</a></li>
            </ul>
        </li>
        <li><a href="#">Categoria 4</a></li>
        <li><a href="#">Categoria 5</a></li>
        <li class="dropdown">
            <a data-toggle="dropdown" class="dropdown-toggle" href="#">Categoria 6<b class="caret"></b></a>
            <ul class="dropdown-menu">
                <li><a href="#">Categoria 6.1</a></li>
                <li><a href="#">Categoria 6.2</a></li>
            </ul>
        </li>
    </ul>

Can anyone help?

Related posts

Leave a Reply

1 comment