Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pm_set_custom_permalink($post_id, $post, $update) {
- global $permalink_manager_uris;
- // Do not trigger when the post is updated
- if($update) { return; }
- // Do not do anything if post is autosaved
- if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; }
- // Ignore auto-drafts & removed posts
- if(in_array($post->post_status, array('auto-draft', 'trash'))) { return; }
- // Update only selected product post type permalinks
- // if(!empty($post->post_type) && $post->post_type !== 'product') { return; }
- if(!empty($permalink_manager_uris) && empty($permalink_manager_uris[$post_id])) {
- $default_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri($post_id);
- if($default_uri) {
- Permalink_Manager_URI_Functions::save_single_uri($post_id, $default_uri, false, true);
- }
- }
- }
- add_action('wp_insert_post', 'pm_set_custom_permalink', 100, 3);
Add Comment
Please, Sign In to add comment