Skip to content

Instantly share code, notes, and snippets.

@trepmal
Created January 3, 2014 00:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trepmal/8229946 to your computer and use it in GitHub Desktop.
Save trepmal/8229946 to your computer and use it in GitHub Desktop.
(WordPress snippet) Gets rid of the whitespace between "</li> <li>" in custom nav menus. Why? The whitespace can cause stupid headaches when the li's have `display: inline-block;`
<?php
// note the walker param
wp_nav_menu( array(
'walker' => new No_WhiteSpace_Nav_Menu,
'theme_location' => 'primary',
'menu_class' => 'nav-menu'
) );
// in your theme's functions.php
class No_WhiteSpace_Nav_Menu extends Walker_Nav_Menu {
function end_el( &$output, $item, $depth = 0, $args = array() ) {
$output .= "</li>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment