Created
July 23, 2018 14:42
-
-
Save EmmanuelBeziat/aa11b81fd200200e0c44d63a57339387 to your computer and use it in GitHub Desktop.
WordPress Walker — move custom menu class from list item to link
This file contains hidden or 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 Social_Walker extends Walker_Nav_Menu { | |
function start_el(&$output, $item, $depth, $args) { | |
$classes = empty( $item->classes ) ? array() : (array) $item->classes; | |
$link_class = $classes[0]; | |
$link_target = $item->target == '' ? '' : 'target="'.$item->target.'"'; | |
unset($classes[0]); | |
$output .= '<li class="'. join($classes, ' ') .'">' | |
.$indent.'<a href="'.$item->url.'" title="'.$item->title.'" class="'.$link_class.'" '.$link_target.'>' | |
.$indent.'<span class="sr-only">'.$item->title.'</span>' | |
.$indent.'</a>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment