Tell us what you are trying to do? I have created a post relationship between Club Members (Members) and their Cars (Members Cars). I've then created a list that shows all members details along with their cars. To do this, I've created a view of Members and then added 3 nested views showing their car details. Template as follows:
<td>[types usermeta="membership-no"][/types]</td>
<td>[wpv-post-link]
[wpv-post-author format='meta' meta='wpcf-address-1']
[wpv-post-author format='meta' meta='wpcf-address-2']
[wpv-post-author format='meta' meta='wpcf-city']
[wpv-post-author format='meta' meta='wpcf-county-state']
[wpv-post-author format='meta' meta='wpcf-postcode']</td>
<td>[wpv-view name="members-list-cars-body-model"]</td>
<td>[wpv-view name="members-list-cars-reg-no-and-date"]</td>
<td>[wpv-view name="members-list-cars-chassis-no-and-engine-no"]</td>
I've installed Relevanssi and am trying to get a text search to search and return results from all fields in the list. I've aded the relevant fields to Relevanssi and can return a result on the Members name, address, etc. but am getting no results for any of the Members Cars details. I'm presuming that this is to do with the nested views.
Is there any documentation that you are following? I've looked through lots of posts but the most relevant were:
https://toolset.com/forums/topic/search-filter-for-nested-views/
https://toolset.com/forums/topic/nested-views-many-to-many-relationship-custom-search/
https://toolset.com/forums/topic/wpv_filter_query-not-working-with-nested-view/
Is there a similar example that we can see? The page in question is at hidden link
What is the link to your site? hidden link
I look forward to any thoughts or ideas.
Best regards
James
It is not possible to search in related posts (in any of their data), neither using Toolset or Relevannsi.
The feature is known to be lacking good solutions for searching related data, and the Developers are aware of this, but it requires more time to be implemented, in fact, there is no ETA for this to be added, although we know and will eventually add it at some point.
For now, the only you can do is search by related posts, so that means, using Toolset View's relationship search you can filter posts by let's say their direct ancestor or a parent of an ancestor.
But this will no t allow for searching in fields of those posts.
I've added a voice to the feature as well.
Thank you!
Hi Beda,
Many thanks for getting back to me. Oh, wow! Thats not good. Just to check that we're both understanding:
I have two post types: Members and Members Cars
I have a relationship that links Members to the cars that they own (in Members Cars).
I've created a list of Members and their cars, with example field columns as follows:
---------MEMBERS CPT----------- ---------MEMBERS CARS CPT------------------
MEMBERS NAME | ADDRESS | CAR REGISTRATION | CHASSIS NUMBER
I'd like to be able to add a search box so that users could search for a members name, or car registration.
This isn't possible at present?
If so, is there any way around this or alternative? Merging post types? Keeping the intermediary post type?
Could it be custom coded? (i.e could we write a sql query, etc.)?
Any thoughts welcomed as I'd really like to use Toolset for this part.
Best regards
James
Hello James,
Beda has left the team, so, I am taking over some of his tickets.
It is not possible to filter a view with another custom post type fields. A view can only filter with the post custom fields. A view can have only one relationship filter and can contain multiple taxonomy and custom field filters.
We can always filter the query of the view using the wpv_filter_query. Check this documentation article https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
That can be used for a workaround. You can hook into the view query filter, then search for members cars, get the user members ids and pass them using the "post__in" to the query arguments of the view, the filters of the views will be applied only to the members that were added to the query filter. Check this https://developer.wordpress.org/reference/classes/wp_query/#post-page-parameters
Check the Toolset relationships API for useful functions https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
I hope this helps. Let me know your feedback.
Many thanks Jamal. I'll research the filter query options and come back if I have any further questions.
Kind regards
James