Last active
September 7, 2016 23:55
-
-
Save thewebprincess/6619453 to your computer and use it in GitHub Desktop.
You know those times when you want to make a widget title a link? And WordPress strips HTML? Here's a handy way to do that... Paste the code below in your functions file and then use square brackets instead of angled ones when writing your link around the title. For Example = [a href="http://mywebsite.com"] Link [/a] - WordPress doesn't recogniz…
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 | |
add_filter( 'widget_title', 'your_html_widget_title' ); | |
/** | |
* html_widget_title function. | |
* | |
* @access public | |
* @param mixed $title | |
* @return void | |
*/ | |
function your_html_widget_title( $title ) { //HTML tag opening/closing brackets | |
$title = str_replace( '[', '<', $title ); | |
$title = str_replace( '[/', '</', $title ); | |
$title = str_replace( ']', '>', $title ); | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a bug here. Line 16 will never do anything as line 15 will have replaced all
[
characters with<
characters.Still useful though :)