Skip to content

Instantly share code, notes, and snippets.

@svebal
Last active October 10, 2017 19:09
Show Gist options
  • Save svebal/f8fbb83a584fee88a1bbf20a07f48460 to your computer and use it in GitHub Desktop.
Save svebal/f8fbb83a584fee88a1bbf20a07f48460 to your computer and use it in GitHub Desktop.
[Wordpress] allow HTML tags in widget titles
<?php
// 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 shortcode like pseudo code
// just replace < & > with [ and ]
// if css classes should be added to HTML tag, write them quotes
//
// example:
// Title with [span class=my_class_without_quote]span Tag[/span]
//
// result:
// Title with <span class="my_class_without_quote">span Tag</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment