Simple HTML in widget title

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
<?php
function html_widget_title( $title ) {
	//HTML tag opening/closing brackets
	$title = str_replace( '[', '<', $title );
	$title = str_replace( '[/', '</', $title );

	//<strong></strong>
	$title = str_replace( 's]', 'strong>', $title );
	//<em></em>
	$title = str_replace( 'e]', 'em>', $title );

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

Instructions:

By default all HTML tags are being stripped down for widget titles in WordPress. This bit of code makes it easy to use simple HTML tags replacements in those titles like so: “Testing [s]strong[/s] and [e]emphasized[/e]“.

The snippet makes it possible to use (type [s] and [/s] in widget title) and (type [e] and [/e] in widget title) tags only but other HTML tags can be added easily.


Related links:
http://www.lemmonaid.info
Share this snippet

If you like this snippet, share it with friends!