Last active
November 4, 2016 10:16
-
-
Save alexstandiford/a03615c2ddefa5974955bb6e66d24f60 to your computer and use it in GitHub Desktop.
Basic Nav Menu Walker Structure for custom WordPress themes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class myWalker extends Walker_Nav_Menu { | |
// Displays start of a level. E.g '<ul>' | |
// @see Walker::start_lvl() | |
function start_lvl(&$output, $depth=0, $args=[]) { | |
$output .= '<ul>'; | |
} | |
// Displays end of a level. E.g '</ul>' | |
// @see Walker::end_lvl() | |
function end_lvl(&$output, $depth=0, $args=[]) { | |
$output .= '</ul>'; | |
} | |
// Displays start of an element. E.g '<li> Item Name' | |
// @see Walker::start_el() | |
function start_el(&$output, $item, $depth=0, $args=[]) { | |
$output.= '<li>'.esc_attr($item->title); | |
} | |
// Displays end of an element. E.g '</li>' | |
// @see Walker::end_el() | |
function end_el(&$output, $item, $depth=0, $args=[]) { | |
$output .= '</li>'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment