Advertisement
TourKick

Set WordPress shortlink to siteurl.com/1234

Dec 12th, 2012
200
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // By Clifford Paulick of http://tourkick.com/
  2. //
  3. // RESULTS IN SETTING http://siteurl.com/1234 AS THE SHORTLINK
  4. //
  5. // MAKE SURE YOU ENABLE THESE LINKS TO WORK VIA SOME METHOD, like http://managewp.com/?p=377184
  6. //
  7. function post_id_shortlink() {
  8. global $post;
  9.     if ( is_singular() ) {
  10.         $postid = $post->ID;
  11.             $idshortlink = site_url() . '/' . $postid;
  12.             return $idshortlink;
  13.         }
  14.     }
  15. add_filter( 'pre_get_shortlink', 'post_id_shortlink', 99); // priority 99 overrides bit.ly and other plugin's default priority of 10
Advertisement
RAW Paste Data Copied
Advertisement