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 Sub Menus

I recently did the Wordpress portfolio project on here and we used the following code to strip the menu li tags: <?php $args = array( 'menu' => 'main-menu', 'echo' => false ); echo strip_tags(wp_nav_menu( $args ), '<a>'); ?>

Which produced an output like this:

<ul> <a href="#">Menu 1</a> <a href="#">Menu 1</a> <a href="#">Menu 1</a> </ul>

The problem is when I add in sub-menu items in wordpress the output now looks like this:

<ul> <a href="#">Menu 1</a> <a href="#">Sub-Menu 1</a> <a href="#">Sub-Menu 2</a> <a href="#">Menu 1</a> <a href="#">Menu 1</a> </ul>

My problem is that I cannot figure out how to select the sub menu items in CSS to create a drop down menu. Normally I would use selectors to target the ul's that are within line items and create the drop down by hiding these and showing them on hover.

If anyone can help me figure how to create a drop down with this stripped menu I would be very appreciative!

Chris Dziewa
Chris Dziewa
17,781 Points

I'm trying to figure this out too. I believe it has to do with extending the walker class in wordpress but the codex doesn't have good documentation about it. If I figure it out, I'll let you know.