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.

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:

  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

share|improve this question
    
How is "shifts the sequence" different from reordering? I am not sure what you mean. –  s_ha_dum Nov 7 '12 at 15:33
    
Shifting means that a-b-c becomes b-c-a or c-a-b as you just slide items from the top to the bottom of the queue. The sequence remains the same. Reordering means to me that you put items in the order you want. You can't get a-c-b from shifting a-b-c, you need to reorder the sequence. –  Bachir Messaouri Nov 7 '12 at 15:38
add comment

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
Thank you. Your answer is way more elaborate than mine (see edit on the original post). –  Bachir Messaouri Nov 7 '12 at 16:10
    
It looks like maybe you were editing core files which is always a headache long term. –  s_ha_dum Nov 7 '12 at 16:12
    
Thank you I know. The thing is this website is meant to live 48h only. I have a hard time finding out what is the right hook I have to use in the functions.php file... –  Bachir Messaouri Nov 7 '12 at 21:02
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.