How to add BR tag in navigation menu items in WordPress

Sometimes you may want to add a line-break in a navigation menu item in WordPress.

In this case, you can add the following function to functions.php under your theme (or child theme) and add ##BR## within menu items.

function wpa_105883_menu_title_markup( $title, $id ){
 if ( is_nav_menu_item ( $id ) ){
 $title = str_ireplace( "#BR#", "<br/>", $title );
 }
 return $title;
 }
 add_filter( 'the_title', 'wpa_105883_menu_title_markup', 10, 2 );
 (Source: http://wordpress.stackexchange.com/)

Of course, you can use other unique string instead of #BR#.


Leave a Comment