I'm working on a pretty complicated site where everything is managed by category type including automatic spinner image submission, etc.. Unfortunately, its doggone difficult to manage things when the admin panel "All Posts" sorts them by date (DESC) I'm thinking it sure would be handy to have the show "All Posts" in category name order.
I Found this small routine, that works for sorting by Post name.
/*
Plugin Name: Set Post Order In Admin
Version: 0.1
Plugin URI: http://wordpress.org/support/topic/336715/
Description: In Posts->Edit, display posts in title order.
Author: MichaelH
Author URI: http://codex.wordpress.org/User:MichaelH/MyPlugins
check out: http://codex.wordpress.org/Class_Reference/WP_Query
in the section order and orderby parameters */
function set_post_order_in_admin( $wp_query ) {
if ( is_admin() ) {
$wp_query->set( 'orderby', 'name' );
$wp_query->set( 'order', 'ASC' ); /* ASC or DESC */
}
}
add_filter('pre_get_posts', 'set_post_order_in_admin' );
That works okay for sorting by title, but I really need to be able to sort by category name. I tried playing with the $wp_query->set( 'meta_key', 'category' );
and $wp_query->set( 'orderby', 'meta_value' );
but when I started using those, I just got an empty return for All Posts within my admin panel. Any ideas on what is missing? I've tried a number of terms for meta_key
all of them fail. Anybody been here before? Any idea on how to achieve the goal of sorting All posts in the admin panel by category (parent)??