Support

Account

Home Forums General Issues post title updater not working for pages Reply To: post title updater not working for pages

  • Hi, Im using the above, and it works for me,
    What I added, in order to make the post slug work is this:
    While it works, I am not sure whether it is the best approach, seems to make the saving of a post very slow.

    add_action('save_post', 'set_slug');
    
    function set_slug($post_id){
        $new_slug = get_post_meta($post_id,'custom-slug', true);    
        $post_args = array(
            'ID' => $post_id,
            'post_name' => $new_slug,
        );
    
        wp_update_post($post_args);
    }