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 trialAriel Beninca
6,390 Pointshow to make my Wordpress menu a drop down
how to make a wordpress drop down menu i followed the tutorial and it did not explain how to do drop down menus it did not explain allot of things and was extremely basic and now i am trying to develop a Wordpress theme and there is heaps i don't know how to do.
8 Answers
Nathalie C
2,594 PointsI targeted the ul directly to get mine to work. Have you tried being more specific with your css selectors, e.g. in this case ul#menu-main-menu and ul#menu-main-menu ul.sub-menu? Do you have a link to your page to look at?
I didn't strip away any classes or ids but wrapped the menu php function within a tag with the appropriate ids / classes that I wanted applied to that tag.
Ah I remember I also had to double check how I had wrapped the jquery script so it would work correctly in wordpress on the main theme.js. It should have been corrected now, but here’s the link for that-
https://teamtreehouse.com/forum/corrections-to-how-to-build-a-wordpress-theme
marcinlisewski
19,839 PointsI think here you should find answer : http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus This is article from theme developer about menus in themes.
Best Regards
Ariel Beninca
6,390 PointsThankyou ! This is actually the most helpful information yet
Nathalie C
2,594 PointsI was able to create an accordion drop down menu after watching the treehouse tutorial. How you choose to manipulate the menu whether by using css, jquery etc. doesn't change from how you would apply to a static html site build. The difference is as I understood it, that your menu is dynamic, so any pages created or deleted automatically change in the menu without you having to manually go in and add remove pages by hard coding. But the principles of how to style and add functionality to that menu remains the same. No plugins used either.
Ariel Beninca
6,390 Pointsso your saying that t automatically activates the drop down menu and my css is the problem ? on the html version of my website drop down menus worked with the treehouse method of activating the menu the menu did work but it was not drop down.
Ariel Beninca
6,390 Pointsok so what i need to do is change the way wordpress outputs it and get rid of there classes and ids currently Wordpress does this
<div class="menu-main-menu-container">
<ul id="menu-main-menu" class="menu">
<li id="menu-item-48" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-5 current_page_item menu-item-48"><a href="#">Home</a></li>
<li id="menu-item-49" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-49"><a href="#">About</a></li>
</ul>
</div>
i need this for my css to work
<div id="navigation">
<ul>
<li class="parent"><a href="#">top menu item</a>
<ul>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
</ul>
</li> <li class="parent"><a href="#">top menu item</a>
<ul>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
</ul>
</li> <li class="parent"><a href="#">top menu item</a>
<ul>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
<li><a href="#">sub menu item</a></li>
</ul>
</li>
</ul>
</div>
```
Nathalie C
2,594 PointsI targeted the ul directly to get mine to work. Have you tried being more specific with your css selectors, e.g. in this case ul#menu-main-menu and ul#menu-main-menu ul.sub-menu? Do you have a link to your page?
Ariel Beninca
6,390 Pointsstarting to think treehouse is not the best way to learn Wordpress theme development, the tutorial was extremely basic, in reality we would need to know allot more. So so so so so much they did not cover. It would be impossible to build a professional theme for Wordpress that you would sell based on only the knowledge that was given .
Ariel Beninca
6,390 PointsShould it add drop down menus automatically or do you have to allow it from functions php ?
marcinlisewski
19,839 PointsOK, so menu code is in header.php.
Function wp_nav_menu() is responsible for generating menu.
Here can you find args for that function http://codex.wordpress.org/Function_Reference/wp_nav_menu
You should compare you html template to wordpress template (section menu) and edit header.php in wordpress theme so in the end you had simillar divs, id's and classes like in your html template.
BR
Ariel Beninca
6,390 Pointsi already have that function wp_nav_menu() and my menu is display perfectly it is just not showing any drop down items. Comparing it to other themes that have drop down menus, they had a whole page for the menus called menu.php and i did not understand what they did, it was extremely different from what treehouse taught and did not work when i tried to apply it to my theme. Thankyou :)
marcinlisewski
19,839 PointsOK, so menu code is in header.php.
Function wp_nav_menu() is responsible for generating menu.
Here can you find args for that function http://codex.wordpress.org/Function_Reference/wp_nav_menu
You should compare you html template to wordpress template (section menu) and edit header.php in wordpress theme so in the end you had simillar divs, id's and classes like in your html template.
BR
marcinlisewski
19,839 PointsI so disagree with you.
Just install the plugin from here http://wordpress.org/plugins/dropdown-menu-widget/
I just spend few seconds with google to find it.
BR
Ariel Beninca
6,390 Pointsi already have the css for my menu and for it's drop down, and the javascript for it, it was originally a html website.
also when using plugins and then exporting the theme i don't think it exports plugins with it so you would have to integrate it with the theme. It should not take a plugin to do a drop down menu we should know how to do it ourselves.
Not sure you understand i want to make professional Wordpress theme to sell.
Though thankyou for your input :)
Ariel Beninca
6,390 PointsAriel Beninca
6,390 Points