[Closed] Relatioship Posts-Products search by title and SKU
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hi, I've Toolset and WooCommerce installed. I've created the many-to-many relatioship Posts-Products.
When I use the Connect Existing Products button to connect Products to the Post, it seems that the searchbox searches in the title and also in the product decription (see image, I look for a word and it displays also results without that word in the title).
Is it possible to limit the search only to the title? Is it also possible to search by SKU?
I located the plugin code that handles the requests for these text searches when you are connecting related posts, and I followed through the details.
In the end it uses a standard WP_Query to search for the related posts, using the 's' search parameter.
That searches both the post_title and the post_content, and there isn't a simple way to change that behaviour (nor to add other fields such as the SKU).
There aren't any filters that you can use to intervene in the Toolset code to modify this.
The only option if you need to do this would be to look at the available filters for the WP_Query::get_posts method and modify the generated SQL. The posts_search filter would be your best route in, see https://developer.wordpress.org/reference/hooks/posts_search/
If you add a callback to the posts_search filter then you should be able to inspect the $_REQUEST or $_POST globals, the admin-ajax call is submitted with an action "types_related_content_action".
Try dumping $_REQUEST and $_POST to the debug.log in your filter callback and inspect the contents, you should be able to determine whether that action is present or not and how it appears in either global variable to be able to test for it.
The topic ‘[Closed] Relatioship Posts-Products search by title and SKU’ is closed to new replies.