How to change redirect after moving a page to trash?

How could I change the redirect location after a user trashes a page?
Right now they go to all pages here:….wp-admin/edit.php?post_type=page

I want them to go here:……wp-admin/edit.php?post_type=page&page=custom_page_order

Related posts

Leave a Reply

1 comment

  1. Hook into load-{screen_id} and check if the $_GET['trashed'] variable is 1 or above.

    add_action('load-edit.php','wpse_trashed_redirect');
    function wpse_trashed_redirect(){
        $screen = get_current_screen();
        if('edit-page' == $screen->id){
            if( isset($_GET['trashed']) &&  intval($_GET['trashed']) >0){
                $redirect = add_query_arg(array('page'=>'custom_page_oder', 'trashed' => false, 'ids' => false ));
                wp_redirect($redirect);
                exit();
            }
        }
    }
    

    This works – and I’m not aware of a better way of doing this…