WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been following this tutorial to build a sorting page for my posts: http://soulsizzle.com/jquery/create-an-ajax-sorter-for-wordpress-custom-post-types/

The sorting works fine, but the new sorting is not reflected back in the 'All Posts' section under 'Posts', it only displays sorted under the 'Sort Posts' submenu created by this code in the tutorial.

How would I extend this further to also sort the posts correctly under 'All Posts', as it is a bit confusing for the user as it is?

Also, does anybody know why there is no functionality for sorting, especially for pages and custom post types (I can imagine posts being more date-oriented), built into the WP Core?

share|improve this question
up vote 2 down vote accepted

I think this is what you want...

This isn't tested so you may have to fiddle with it.

in your functions.php file, add something like this :

EDIT (2)

After rereading, I saw you're not using custom post types, so i'll change my code accordingly. I don't know how to detect when you're on the 'manage all posts' page, so maybe someone can complete my 'if' statement.

This should work.

 function set_post_order_in_admin( $wp_query ) {
      if ( is_admin() ) {
           if( 'edit.php' === $GLOBALS['pagenow'] ) { 
                $wp_query->set( 'orderby', 'menu_order' );
                $wp_query->set( 'order', 'ASC' );
 add_filter( 'pre_get_posts', 'set_post_order_in_admin' );
share|improve this answer
I'm not sure about the return (if it's necessary). – kaiser Jan 24 '12 at 18:31
@kaiser Removed it, wasn't in the codex either. Never actually used this filter yet. – Shane Jan 24 '12 at 18:44
Excellent thanks so much! – drtanz Jan 24 '12 at 19:46

Your Answer


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.