Created
October 1, 2013 19:19
-
-
Save brasofilo/6783653 to your computer and use it in GitHub Desktop.
Using URLs in Widget Titles. Using the format TITLE||URL||TARGET, being target optional. Nice article with many methods: http://www.rvamedia.com/wordpress/customize-wordpress-widget-title
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', function( $title ) | |
{ | |
$pieces = explode( '||', $title ); | |
if( isset( $pieces[1] ) ) | |
{ | |
$target = isset( $pieces[2] ) ? "target='{$pieces[2]}'" : ''; | |
$new_title = sprintf( | |
"<a href='%s' %s>%s</a>", | |
$pieces[1], | |
$target, | |
$pieces[0] | |
); | |
} | |
$return = isset( $new_title ) ? $new_title : $title; | |
return $return; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment