Search breaks on list tables
paulgibbs opened this issue · 1 comments
When I'm on the list table index of a CPT I've registered with this plugin (e.g. example.com/wp-admin/edit.php?post_type=hubs), and do a search using the standard search box at the top-right of the screen (e.g. "Search Hubs"), WordPress loads the new page with the search results.
However, on the results screen, it has searched for matches across all CPTs, not the one I was previously on. The GUI of wp-admin still says I'm on the "Hubs" CPT. The URL looks like this:
https://example.com/wp-admin/edit.php?s=joke&post_status=all&post_type=hubs&action=-1&m=0&paged=1&action2=-1
It appears that while the post_type parameter is set on the URL, WP still searches all the posts regardless of type.
I'd appreciate a second opinion if it's some weird wp_query filter on my side that's messing the query, or not.
This is with WP 5.4.2 and xCPTS 4.4.0.
I've tested this with a vanilla WordPress 5.4 installation and ExtCPTs 4.4 and I can't reproduce the issue.
The SQL for the main query looks like this:
SELECT wp_posts.ID, wp_posts.post_parent
FROM wp_posts
WHERE 1=1
AND (((wp_posts.post_title LIKE '%joke%')
OR (wp_posts.post_excerpt LIKE '%joke%')
OR (wp_posts.post_content LIKE '%joke%')))
AND wp_posts.post_type = 'hubs'
AND (wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'private')
ORDER BY wp_posts.menu_order ASC, wp_posts.post_title ASC
If you go to the Request
menu in Query Monitor and check its Hooks In Use
submenu it should show you if something else is hooking into a request related action or filter and messing with the results.