Last active
October 10, 2017 19:09
-
-
Save svebal/f8fbb83a584fee88a1bbf20a07f48460 to your computer and use it in GitHub Desktop.
[Wordpress] allow HTML tags in widget titles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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