Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

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...

share|improve this answer
    
I think this is close. I get this url:/wp-admin/edit.php?post_type=page&trashed=1&ids=112&page=custom_page_oder It needs to be: wp-admin/edit.php?post_type=page&page=custom_page_order –  Shae May 22 '12 at 20:08
    
I can't get it to remove the trash id from the URL? Any ideas? –  Shae May 24 '12 at 12:24
    
I just edited the answer to make it remove ids and trash variable from the redirected url –  Shazzad Dec 11 '13 at 16:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.