Wednesday, November 26, 2014

Wordpress: Allow HTML tags in text widget title



Sometimes you get more stylish design in your theme and you want to style or add tags in title. So when you stuck and want to put HTML tags in widget title in WordPress.
Here below I have made a function which will allow you to do so.



<?php
/*
* Author : TechnoKnol
* Blog : http://technoknol.blogspot.com
* Purpose : Allow HTML tags in Widget Title in WordPress
*
* */
// Add below code in your theme's functions.php file
// Allow HTML tags in Widget title
function html_widget_title( $var) {
$var = (str_replace( '[', '<', $var ));
$var = (str_replace( ']', '>', $var ));
return $var ;
}
add_filter( 'widget_title', 'html_widget_title' );
// Usage : Use Forum type BB code styling just replace < & > with [ and ]
// If you wanna give class to tag , Apply without Quote.
// See Example Below.
Title with[span class=class_without_quote ]span Tag[/span]


Above you can see example, you just have to give tags in square brackets instead of angular. And you can give one class also (without quote ;) ).

Related Posts Plugin for WordPress, Blogger...