Last active
August 29, 2015 14:23
-
-
Save webmasterninjay/7a8ad754fade90ac4701 to your computer and use it in GitHub Desktop.
WP Genesis: Add external link on Post Title
This file contains hidden or 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 | |
// Filter post title | |
// to add custom url, just add a custom field with name ExternalURL and url as value where you want the title to go when clicked | |
add_filter( 'genesis_post_title_output', 'jay_post_title_output', 15 ); | |
function jay_post_title_output( $title ) { | |
if ( is_singular() && get_post_meta( get_the_ID(), 'ExternalURL', true) ) | |
$exturl = get_post_meta( get_the_ID(), 'ExternalURL', true); | |
$title = sprintf( '<h1 class="entry-title"><a href="%s" title="%s" target="_blank">%s</a></h1>', $exturl, get_the_title(), get_the_title() ); | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment