Welcome to the Treehouse Community
Looking to learn something new?
Styling the nav in WordPress
I know there are some more videos coming soon about styling the wp theme but I was trying to add some CSS to the wp_nav_menu in the header.php page and was having some trouble. When I tried adding a div class my wp_nav_menu, my site went blank.
<p> This is the header </p> <?php $args = array( 'menu' => 'main-menu' ); wp_nav_menu( $args ); ?>
John Locke15,479 Points
@ardon You might want to try something like this instead.
<?php wp_nav_menu( array('menu' => 'Main Navigation' )); ?>
where Main Navigation is the name of your top level navigation menu.
I use Chrome Developer Tools (right click) > Inspect Element to see what the class is, and then write accordingly. If I need to add a class, I can either wrap it in another div, or try to figure out where in the PHP it is writing the menu, and have it add a class there.
Thanks for the suggestion, John! I'm going to play around with that.
I was up for a few hours last night trying to figure out why my menu wouldn't style. My nav id wouldn't show up in inspector. I reinstalled everything and that did the trick. When all else fails, reinstall eh. Thanks again.