Pages

Tuesday, March 26, 2013

Add HTML tags to widget title [ wordpress ] - resolved


If you want to add HTML tags to widget tile then please write below code in "functions.php"
<?php
function html_widget_title( $title ) {
 //HTML tag opening/closing brackets
 $title = str_replace( '[', '<', $title );
 $title = str_replace( '[/', '</', $title );

 //<span></span>
 $title = str_replace( 'span]', 'span>', $title );

 return $title;
}
add_filter( 'widget_title', 'html_widget_title' );
?>

Example:       
[span]Your Text[/span]

No comments: