Monday, 23 September 2013

Add html tag in wordpress nav menu item

If you want to add a html line break and other tag in the custom  menu title in wordpress then bellow code will be helpful add these codes in the function.php file of your theme folder.



Add following code in function.php file of your theme.


<?php 
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 );

?>


Now you can use "#BR#for <br /> in your custom menu title.






No comments:

Post a Comment