Hi, I've a custom search with few taxonomy filters. I need to display all the results that matches with any term of the search, so I've to set an OR relationship btw filters, so if I filter by:
TAX1 term1, term2
TAX2 termA
I want to display this result:
Entry1 (TAX1 term1, term2)
Entry2 (TAX1 term1 - TAX2 termA)
Entry3 (TAX1 term1, term2 - TAX2 termA)
Entry4 (TAX2 termA)
This is what Views do by default.
Now I need to order result by terms matching, so this should be the order of the result:
Entry3 (TAX1 term1, term2 - TAX2 termA)
Entry2 (TAX1 term1 - TAX2 termA)
Entry1 (TAX1 term1, term2)
Entry4 (TAX2 termA)
Is it possible?
Then I also would like to display on each entry in the loop witch terms match with that specific entry. I tryed using:
[wpv-conditional if="( has_term('[wpv-search-term param='wpv-tax1']', 'tax1', null) eq '1' )" ]
[wpv-search-term param='wpv-eating-problem']
[/wpv-conditional]
But this works only if I select 1 term of TAX1, if I select more then one it doesn't.
Is there a solution?
thanks
Now I need to order result by terms matching,
This might be possible with some custom code using the APIs wpv_filter_query or wpv_filter_query_post_process, but it's not something you can accomplish from wp-admin using Views. Views' sorting algorithm is based on WordPress's WP_Query, which does not offer any Order or OrderBy options based on "best match" of specific taxonomy filters:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
The "relevance" option only applies to text search terms, not taxonomy or custom field searches.
Here's a ticket that uses wpv_filter_query_post_process to inspect the query for taxonomy criteria, then manipulates the query results directly based on those criteria: https://toolset.com/forums/topic/filter-does-not-work-2/#post-556139
It might give you a good idea of how to get started with this custom code. Your solution will be more complex, and isn't something I can offer a quick fix for. More information about the filter API:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process
Then I also would like to display on each entry in the loop witch terms match with that specific entry.
This sounds like a separate issue from ordering results. May I kindly ask you to create a separate ticket? This will help us keep the forum organized and help other users find solutions to similar questions.