Tell us what you are trying to do?
I am trying to create a filter that has custom fields and repeatable custom fields (for example 'wpcf-rc-camps-pow') of the 'rc-camps' group for posts of the custom type 'rc-roll-call'.
Now I have created a filter displayed on page as 2 groups of filters, the first group of parameters by custom fields, the second group by repeatable fields. The results are displayed correctly if I use parameters from the first group or from the second group as I added the condition of displaying fields depending on the post type [ wpv-conditional if="( '[wpv-post-type]' eq 'rc-roll-call' )"] or [wpv-conditional if="( '[wpv-post-type]' eq 'rc-camps ' )"].
The problem is that when I want to use parameters from the first and second groups, it does not work.
What should I do so that the filters from the first and second groups can work simultaneously and find posts with the post type 'rc-roll-call' without setting the display condition in the search results?
Is there any documentation that you are following?
to generate field output depending on post type used this https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/
Is there a similar example that we can see?
- I didn't find any
What is the link to your site? hidden link
I think the problem is that you are querying two different post types (the main post type and the child post type which stores the repeatable groups of fields) and trying to filter by fields that belong to one or the other but not both.
By default filters would be evaluated with AND, and any one post (of either type) cannot meet field conditions of fields that belong to it as well as fields that do not belong to it.
So the solution would be to switch the evaluation to OR. You may be able to do that within the UI in the Query Filter section of the View (if you cannot see it, expose it via the Screen Options tab at the top of the page).
But cross search doesn't anyway after the wpv_filter_query changed relationship to "OR". Is there any way to make a search to work when parameters from post custom field and repeatable fields are chosen at the same time?
also currently Query Filter UI doesn't allow to changes AND operator to OR, so had to add code
I just set up a test of this on my local site, and it works as intended when using the custom code.
Can I check your site to see that you have it set up correctly?
Let me mark your next reply as private so that we can get log-in credentials from you—you may want to create a temporary admin user for us to use that you can later delete. And be sure to have a current backup of your site.
Can you give me clear steps to test, including some filter values I should select that you would expect to produce results.
OK, what you are describing isn't possible, unfortunately.
It is logically not possible to query multiple post types with filters for fields that are unique to the different post types and combine the filters with AND rather than OR.
In your case, you don't actually want to query the RFG post type, you want to query roll call posts, but be able to filter those posts both by fields which belong to them and by fields which do not (because they belong to the RFG posts).
Because of how RFGs are implemented in Toolset, via child posts, you need to filter posts by fields of related posts (the child posts), and that is not supported I'm afraid. You can only filter posts by fields that belong to those posts, which means the fields you want to filter by that are part of repeatable field groups really need to be reassigned so that they belong directly to the posts and are not part of repeatable groups.
I don't really have a solution for you. If you wanted to try and get it to work it would involve hooking into the WP_Query filters responsible for generating the JOIN and WHERE clauses of the resulting SQL query and modifying them, but it is a complex and ambitious task.