Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
webmaster74

Enhancement: Allow limiting search to page post titles

When using the inline editing option with a field that provides a search box for posts/pages, it would be great to have the option to search only the title of the post/page/etc. instead of including the contents of those posts/pages. The way it currently works, a bunch of posts/pages are returned so you have to scroll through them continually. A site with thousands of pages makes it challenging to quickly select the post/page you’re looking for. We did find a bit of code to add to our functions.php file, but it affects all admin searches. It’d be nice to have a checkbox to tic by field instead ;)

https://stackoverflow.com/questions/54155517/how-to-limit-wp-admin-to-search-only-titles

Thanks

3 years, 10 months ago
Stefan van den Dungen Gronovius
Developer

Our search option also goes through that hook that you mentioned.
You could use that hook to alter the behavior but you’ll need to make it more specific.
Since inline editing search is performed on an Ajax call, you could at least add the following conditional:

wp_doing_ajax

Besides that, our call contains a few params that you can check. For inline editing, you can check for the action parameter to be ‘acp_editing_single_request’. So the conditional for that can be:

'acp_editing_single_request' === filter_input( INPUT_GET, 'action')

So in the example code from Stack Overflow the first lines that are used for that conditional can be something like this.

if ( 'acp_editing_single_request' !== filter_input( INPUT_GET, 'action') ){
  return $search
}
3 years, 10 months ago

You must be logged in to reply to this topic.