We are implementing ajax based search on hidden link using wp_query
It is supposed to search publication and author CPT both at a time. Both these CPT's are related using toolset relationship feature.
Searching in one CPT is fine and not an issue but as we have to search the related CPT, it would be great if you could
provide me any article which would guide me in correct direction.
We are not using Views, everything is directly coded in the template files.
Using Toolset Views or Toolset Blocks to build queries and searches (which is the purpose of these Toolset components), then you can search for related posts while listing the other related post type, but not in those posts
It is suggested to request this feature at https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/.
Currently, this is what you can do:
1. You can create a Post Relationship and connect posts
2. You can then list let's say the "child" post type in a View and display all data related to that post type and of the related post type in the View loop.
3. You can also add search by data of the currently displayed post type in that View, such as custom fields.
4. Additionally, you can add filters by the related posts meaning you can filter by the related post title, so only those posts connected to a post set in the filter would display as search results.
What you cannot do, is search for Post Data (fields, etc) of the related custom post type. This requires a new Feature to be implemented:
To search in related post custom fields (and other data) when listing posts in a relationship using Views or Blocks.
If you build the query manually you need to apply custom code, which we cannot provide in the Support Forum here.
However, the Toolset Relationships API could be helpful to get related posts (and its data, using native WordPress get_post_meta for example, for fields):
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
The relationships are stored in custom tables, so you cannot query in a WP_Query directly, because it does not know that you will need to look for the relationship data in a custom table.
WP QUery will only query the native tables.
Hence with the Toolset API you could get related posts, and then the data of that related post and query that.
However, this is custom code that we can only assist with documentation and examples as provided in it, about our own API.