Created
May 23, 2013 15:26
-
-
Save anonymous/5636916 to your computer and use it in GitHub Desktop.
Filter Pay with a Like URL to use 'shorturl' post meta
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
function my_filter_pwal_url_to_like( $url_to_like ) { | |
// Try to determine the post_id from the URL. Does not always work | |
$post_id = url_to_postid( $url_to_like ); | |
// IF we find a match then use the post_id to look up the post meta key 'shorturl' | |
if (intval($post_id) > 0) { | |
$shorturl = get_post_meta($post_id, 'shorturl', true); | |
if (!empty($shorturl)) | |
return $shorturl; | |
} | |
return $url_to_like; | |
} | |
add_filter( 'pwal_url_to_like', 'my_filter_pwal_url_to_like'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment