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 trialBoris Kamp
16,660 Pointsedit wp_nav_menu output
Hi guys!
I want to edit the output of my menu. I've set it up this way:
$args = array(
'menu' => 'header-menu',
'menu_class' => 'nav navbar-nav',
'container' => 'false',
//'link_before' => '<i class="fa fa-home"></i>',
);
wp_nav_menu( $args );
note the commented out link before
, I want that to only to display in the first <li>
now I read somewhere I can edit the first <li>
class by doing so:
// add home i to first list item in menu
function first_li_menu_before($items) {
$items[1]->classes[] = 'first';
return $items;
}
add_filter('wp_nav_menu_objects', 'first_li_menu_before');
Now I thought I could use $items[1]->link_before[] = '<i class="fa fa-home"></i>';
to prepend the glyphicon, but it does not work. I have found no way to debug $items
so I dont know how the object is constructed so I can target it right.
any ideas?
Thanks!