I am using the Custom List Table Example plugin as a basis to create my own custom list table. Everything is great, except one thorny point.

When I am processing bulk actions via the process_bulk_action() method, I would like to redirect using wp_redirect(). Here is an example:

function process_bulk_action() {

    // Some security check code here

    // Get the bulk action
    $action = $this->current_action();

    if ($action == 'bulk_trash') {

        // Code for the "delete process"

        // Assuming "delete process" is successful


Please note, in the call wp_redirect("http://url/path.php?update=1&message=some_message"), I am trying to redirect to the same page that displays the list table in order to reload it with the result of the trash process. Also note that there is a message in the path that allows me to display a notification to the user regarding the result of the bulk action.

The problem is, I get an error message Cannot modify header information - headers already sent by <file path>.

I understand what the message means, and the reasons behind it (the page is already loaded and cannot be redirected). However, how do I redirect then if I would like to do that after I process the bulk action? If redirect is not the correct solution, what other options do I have that allow me to re-load the custom wp_list_table again so that the listed records reflect items being deleted (i.e., less published items, and more items in trash)?



You need process you bulk actions in admin_action_{ACTION_NAME} hook. Not in wp_list_table class. Read more here

  • don't work with action2 from bottom of list table :( – DARK_DIESEL Aug 30 '18 at 13:57

echo 'document.location="'http://url/path.php?update=1&message=some_message'";'; This solved my problem

  • 1
    Welcome to WPSE! Please do not just dump code but explain how and what it does so people can actually learn instead of just Copy&Paste code. – kraftner Jul 5 '17 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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