Advertisement
Guest User

Untitled

a guest
Feb 4th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. function pm_stop_product_uri($bool, $post) {
  2.     if(!empty($post) && $post->post_type == 'product' && $post->post_title == 'Product') {
  3.         return false;
  4.     }
  5.    
  6.     return $bool;
  7. }
  8. add_filter('permalink_manager_allow_new_post_uri', 'pm_stop_product_uri', 9, 2);
  9. add_filter('permalink_manager_allow_update_post_uri', 'pm_stop_product_uri', 9, 2);
  10.  
  11. function pm_set_custom_permalink($post_id, $post) {
  12.     global $permalink_manager_uris;
  13.  
  14.     // Update only selected product post type permalinks
  15.     if(!empty($post->post_type) && $post->post_type !== 'product') { return; }
  16.  
  17.     if(!empty($permalink_manager_uris)) {
  18.         $default_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri($post_id);
  19.  
  20.         if($default_uri) {
  21.             $permalink_manager_uris[$post_id] = $default_uri;
  22.             update_option('permalink-manager-uris', $permalink_manager_uris);
  23.         }
  24.     }
  25. }
  26. add_action('save_post', 'pm_set_custom_permalink', 100, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement