Have you ever wanted to do a little something extra special with a sidebar widget title?
If you have, you quickly learn that WordPress strips out all of the HTML tags, making it absolutely impossible to do so.
But there’s a way.
With this snippet, you can add some bold and italics text awesomeness if you like (or other HTML tags for that matter).
Here’s how:
How-To Add Simple HTML in a WordPress Widget Title
As with most WordPress snippets, you’ll want to drop this bit of code in your functions.php theme file or create/add this to a functionality plugin.
Here’s the snip:
//HTML tag opening/closing brackets
$title = str_replace( '[', '$title = str_replace( '[/', '
//
$title = str_replace( ‘s]’, ‘strong>’, $title );
//
$title = str_replace( ‘e]’, ‘em>’, $title );
return $title;
}
add_filter( ‘widget_title’, ‘html_widget_title’ );
?>
And that’s it!
This example will take care of your bold and italics, but you can play around and add other HTML tags, too!
Have fun!
[via WP-Snippets]




No Responses.
Be the first to start the conversation.