Admin Default Sorting for Custom Post Type
-
I am going crazy. I have been Googling and working on this for hours. I can’t figure out how to set my custom sort on a custom post type (in the admin area) to be ascending by title. Every post I have found uses some form of this.
$wp_query->set('orderby', 'title'); $wp_query->set('order', 'asc');
I have tried changing the priority, I have added
die
to make sure that the function itself is running. I’ve done avar_dump()
to check that theorder
andorberby
are properly set. Nothing changes. My eventual goal is to only apply the default sort to a CPT, but I’ll settle for having my code do anything at all at this point. Any ideas on what I’m doing wrong? Thanks so much. Here is one (of many) of the snippets I’ve tried.function set_post_order_in_admin( $wp_query ) { $wp_query->set( 'orderby', 'title' ); $wp_query->set( 'order', 'ASC' ); } add_filter('pre_get_posts', 'set_post_order_in_admin', 5 );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Admin Default Sorting for Custom Post Type’ is closed to new replies.