All, published and pending order

On the list tables of the administration panels, I want to change the order of the filters on top of the table.

What I want:

Read More
  1. Pending
  2. Published
  3. All

I tried to act on a line from the “wp-list-table” file which is by default:

$status_links = array_merge( 
    array_slice( $status_links, 0, $split ),
    array_slice( $status_links, 0, $split ) 
);

The default display is this:

  1. All
  2. Published
  3. Pending

And if I change it to this:

$status_links = array_merge( 
    array_slice( $status_links, 1, $split ),
    array_slice( $status_links, 0, $split ) 
);

I get this order:

  1. Published
  2. Pending
  3. All

And if I change it to this:

$status_links = array_merge( 
    array_slice( $status_links, 2, $split ),
    array_slice( $status_links, 0, $split ) 
);

I get this order:

  1. Pending
  2. All
  3. Published

I believe I will never get what I want from there as this only shifts the sequence but doesn’t reorder it.
How can I do to get my specific order then?

PS: I don’t use the “Scheduled” status and never will.

Thank you.

EDIT:

I Found the solution:

$status_links = array
( 
    $status_links["pending"],
    $status_links["publish"],
    $status_links["all"] 
);

Thank you

Related posts

Leave a Reply

1 comment

  1. Filter views_edit-post.

    function tst($a) {
        // var_dump(get_defined_vars());
        $tst = array();
        $tst['future'] = $a['future'];
        $tst['publish'] = $a['publish'];
        $tst['all'] = $a['all'];
        return $tst;
    }
    add_filter('views_edit-post','tst');
    

    You can juggle that new array however you want. The only keys that are present in the incoming array are the one that have posts so you should check that the key is set before trying to use it. Otherwise, that should do it.