Created
June 7, 2017 13:46
-
-
Save MattRyanCo/afedd478276ac0079012fc11f4941ec5 to your computer and use it in GitHub Desktop.
Make Widget Title Linkable
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
// We will make use of widget_title filter to | |
//dynamically replace custom tags with html tags | |
add_filter( 'widget_title', 'accept_html_widget_title' ); | |
function accept_html_widget_title( $mytitle ) { | |
// The sequence of String Replacement is important!! | |
$mytitle = str_replace( '[link', '<a', $mytitle ); | |
$mytitle = str_replace( '[/link]', '</a>', $mytitle ); | |
$mytitle = str_replace( ']', '>', $mytitle ); | |
return $mytitle; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replaces widget title: [link href=/contact/]Contact Us[/link]
with
<a href="/contact/">Contact Us</a>