Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Ricardo Martins
Ricardo Martins
16,909 Points

Wordpresse nav menu/ dropdown button

Hi,

I'm trying to customize my navigation menu o my wordpresse website. I saw this example on http://divisare.com, and I would like to set up a navigation menu like this one (desktop/mobile views)

Can anyone help me withat, an give me some clues?

I appreciate, Thanks

The default menu structure of wordpress look like this.You have to apply seperate styling for this menu.

<ul id="menu-primary" class="menu">
<li id="menu-item-9" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-9"><a href="http://localhost/wordpress/category/html/">html</a>
    <ul class="sub-menu">
            <li id="menu-item-10" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-10"><a href="http://localhost/wordpress/category/css/">css</a></li>
     </ul>
</li>
<li id="menu-item-15" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-15"><a href="http://localhost/wordpress/category/javascript/">javascript</a></li>
</ul>

you can use seperate class in your php file where navigation registered.

$defaults = array(
               'container' => false,
               'theme_location' => 'primary',
               'menu_class' => 'main-menu' //here you can apply a class and target inside element with this class so it only applied to particular menu
          );

           wp_nav_menu($defaults);

3 Answers

Ricardo Martins
Ricardo Martins
16,909 Points

Thank you Ashish Mehra. I will try to do something with your tip. If i need something, I aks again ;)

sure

Ricardo Martins
Ricardo Martins
16,909 Points

Hi Ashish,

I tried but i guess i don't understood the code that you have posted. I found the code on this webpage ( https://code.tutsplus.com/tutorials/how-to-integrate-a-bootstrap-navbar-into-a-wordpress-theme--wp-33410 ) , but the dropdown function don't work correctly.

Could you be more specific ?

Thanks

is there is any type of error in javascript console ?

Ricardo Martins
Ricardo Martins
16,909 Points

There is someone else that can help me?

I apreciate Thanks