I created a menu in wordpress in the Menus section of the backend is there any way to display the menu links with commas so it displays as Link1, Link2, Link3, Link4
?
2 Answers
Use a very simple custom walker …
class WPSE_82726_Comma_Walker extends Walker
{
public function walk( $elements, $max_depth )
{
$list = array ();
foreach ( $elements as $item )
$list[] = "<a href="https://wordpress.stackexchange.com/questions/82726/$item->url">$item->title</a>";
return join( ', ', $list );
}
}
… and call your menu like this:
wp_nav_menu(
array (
'theme_location' => 'your_registered_theme_location',
'walker' => new WPSE_82726_Comma_Walker,
'items_wrap' => '<p class="menu">%3$s</p>'
)
);
Fast and efficient. 🙂