Advertisement
mbis

Keep old permalinks

May 25th, 2020
1,307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. /**
  2.  * Force original permalinks for old products
  3.  */
  4. function pm_keep_old_permalinks($permalink, $post, $old_permalink) {
  5.     // Ignore new permalinks
  6.     if(strtotime($post->post_date) > strtotime('2020-03-15')) {
  7.         return $permalink;
  8.     }
  9.    
  10.     // Filter only product permalinks
  11.     if(empty($post->post_type) || $post->post_type !== 'product') {
  12.         return $permalink;
  13.     }
  14.    
  15.     return $old_permalink;
  16. }
  17. add_filter('permalink_manager_filter_final_post_permalink', 'pm_keep_old_permalinks', 999, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement