Created
July 28, 2014 19:40
-
-
Save kriot1/f3ffd7852302a8275e43 to your computer and use it in GitHub Desktop.
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
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); // removing the default shortlink | |
add_action( 'wp_head', 'bilty_shortlink_head'); // adding the new bit.ly shortlink | |
function bilty_shortlink_head() { | |
global $post; | |
$shortURL = get_post_meta($post->ID, 'bitlyURL', true); | |
if(!empty($shortURL)) { | |
echo '<link rel="shortlink" href="'.$shortURL.'" />'."\n"; | |
} else { | |
echo '<link rel="shortlink" href="'.get_bloginfo('url').'?p='.$post->ID.'" />'."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment