From 9ccdc30512ccff5270f5bb222b61e561fa594115 Mon Sep 17 00:00:00 2001 From: r-a-y Date: Wed, 1 Jul 2026 00:46:57 -0700 Subject: [PATCH] Allow custom sort order for empty searches in admin area. This notably allows the custom sort order to work when filtering by the 'All dates' or 'All Categories' dropdown filters on the Posts admin dashboard page. --- simple-custom-post-order.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/simple-custom-post-order.php b/simple-custom-post-order.php index 3d5f810..75cbc20 100644 --- a/simple-custom-post-order.php +++ b/simple-custom-post-order.php @@ -1448,11 +1448,13 @@ public function scporder_pre_get_posts( $wp_query ): void { return; } - if ( is_search() ) { + $is_admin = is_admin() && ! wp_doing_ajax(); + + if ( ( $is_admin && '' !== $wp_query->get( 's' ) ) || is_search() ) { return; } - if ( is_admin() && ! wp_doing_ajax() ) { + if ( $is_admin ) { if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { if ( in_array( $wp_query->query['post_type'], $objects, true ) ) { if ( ! $wp_query->get( 'orderby' ) ) {