Created
July 6, 2012 03:12
-
-
Save clarklab/3057857 to your computer and use it in GitHub Desktop.
Simple redirect (URL shortener / tracker) page template
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 | |
| /* | |
| Template Name: Redirect | |
| */ | |
| $redirect_url = get_post_meta($post->ID, 'redirect_url', true); | |
| // get the destination URL | |
| $count = get_post_meta($post->ID, 'count', true); | |
| // get the number of times it's been clicked | |
| $count = $count +1; | |
| //add 1 to the count | |
| update_post_meta($post->ID, 'count', $count); | |
| // update the count post meta | |
| if ($redirect_url) { | |
| wp_redirect($redirect_url); | |
| // shoot the user to the destination URL | |
| } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment