Skip to content

Allow custom sort order for empty searches made in admin area#153

Open
r-a-y wants to merge 1 commit into
ColorlibHQ:masterfrom
r-a-y:fix/empty-search
Open

Allow custom sort order for empty searches made in admin area#153
r-a-y wants to merge 1 commit into
ColorlibHQ:masterfrom
r-a-y:fix/empty-search

Conversation

@r-a-y

@r-a-y r-a-y commented Jul 1, 2026

Copy link
Copy Markdown

Hi,

Thanks for the useful plugin. One of our users noticed that when using the "All dates" or "All Categories" dropdown filters on the Posts admin dashboard page, the custom sort order would not apply.

The issue is when using the "All dates" or "All Categories" dropdown filter, an empty 's' parameter is added to the URL querystring. Even if the 's' parameter is empty, the is_search() function will still return true.

is_search() is used by your plugin to determine whether the custom sort order is used or not:

if ( is_search() ) {
return;
}

So for this PR, I've made a small adjustment to the is_search() line to see if the s parameter is empty or not. If it is empty, allow the custom sort to proceed. I've made it so this is only applied in the admin area to allow frontend searches to work as they have before, but feel free to make changes how you see fit.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant