Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pm_stop_product_uri($bool, $post) {
- if(!empty($post) && $post->post_type == 'product' && $post->post_title == 'Product') {
- return false;
- }
- return $bool;
- }
- add_filter('permalink_manager_allow_new_post_uri', 'pm_stop_product_uri', 9, 2);
- add_filter('permalink_manager_allow_update_post_uri', 'pm_stop_product_uri', 9, 2);
- function pm_set_custom_permalink($post_id, $post) {
- global $permalink_manager_uris;
- // Update only selected product post type permalinks
- if(!empty($post->post_type) && $post->post_type !== 'product') { return; }
- if(!empty($permalink_manager_uris)) {
- $default_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri($post_id);
- if($default_uri) {
- $permalink_manager_uris[$post_id] = $default_uri;
- update_option('permalink-manager-uris', $permalink_manager_uris);
- }
- }
- }
- add_action('save_post', 'pm_set_custom_permalink', 100, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement