按照@Rarst关于安全字符的提示,我最终做了如下工作:
function wpa_105883_menu_title_markup( $title, $id ){
if ( is_nav_menu_item ( $id ) && ! is_admin() ){
$title = preg_replace( \'/#BR#/\', \'<br/>\', $title );
}
return $title;
}
add_filter( \'the_title\', \'wpa_105883_menu_title_markup\', 10, 2 );
Edit: 同样根据Rarst的评论,我已经替换了
preg_replace
具有
str_ireplace
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 );