Guest User

Untitled

a guest
May 5th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. add_filter('post_link','wp_automatic_permalink_changer');
  2.  
  3. function wp_automatic_permalink_changer($permalink ){
  4.  
  5. global $post;
  6.  
  7. if (!empty($post->ID)) {
  8.  
  9. $link_to_source = get_post_meta($post->ID, '_link_to_source', true);
  10.  
  11. if ( trim($link_to_source) != '' ) {
  12.  
  13. $new_permalink = get_post_meta($post->ID, 'original_link', true);
  14. if(trim($new_permalink) != '' ) return $new_permalink;
  15.  
  16. }
  17. }
  18.  
  19. return $permalink;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment