Skip Navigation

[Resolved] Text search by related post

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to include a text search that allows visitors to search for custom posts. I would also like the search to index related posts, so if the visitors sort by parent post title the search should return the related child posts.

Solution: Text search does not currently index related posts, so you could add a post relationship filter to a View of Properties, and let your visitors select an agent by name. Then display the matching Property results.

Or, you could use custom code to copy the Agent's name into a custom field on the property post whenever a Property and an Agent are related to one another. We offer the post relationships APIs toolset_association_created and toolset_before_association_delete to tap into these relationship events. Once that is set up, you can use Relevanssi to add that custom field to the search index. This would allow give you the ability to use a text search field to search Properties by Agent name.

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_association_created
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_before_association_delete

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by nikolaS-3 5 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1223504

Tell us what you are trying to do?
I'm trying to create search box through which you can search custom post type and connected relationship post.
I have two custom post types: Agents and Properties. On the listing page I want to display only properties with all necessery info and also search box where you can search properties by property name and also by connected agent to that property.

So when you search agent's name it should display properties connected to him.

Is that possible?

Thanks!

#1223505

Also can you display data from repeatable group fields on listing page?

#1223576

Hi, it's not currently possible to search by text in a related post, so you would have to handle it a bit differently.
- You could add a post relationship filter to a View of Properties, and let your visitors select an agent by name. Then display the matching Property results.
- You could use custom code to copy the Agent's name into a custom field on the property post whenever a Property and an Agent are related to one another. We offer the post relationships APIs toolset_association_created and toolset_before_association_delete to tap into these relationship events. Once that is set up, you can use Relevanssi to add that custom field to the search index. This would allow give you the ability to use a text search field to search Properties by Agent name.

#1223848

My issue is resolved now. Thank you!