Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Checkboxes AND logic
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 4 years, 2 months ago.
- AuthorPosts
- January 1, 2019 at 7:50 pm #20612
Hello,
I’m using a custom field that displays as checkboxes. Relative to the other fields, the checkbox is AND logic. But it seems relative to ITSELF it is OR. For example, If I check 2 options, the results include matches to EITHER option, as opposed to only matches that match BOTH options. Is there any way to resolve this?
Thank you for the help!
January 2, 2019 at 10:03 am #20616Hi!
Yes, it is possible to change that. On the custom field filter editor screen, there is a checkbox logic option, which is set to ‘OR’ by default. Changing that to ‘AND’ should resolve the issue.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 4, 2019 at 12:39 am #20632My bad, I realize I’m actually using a Dropdown with Multiselect set to true to simulate checkboxes. This is due to the fact the styling of checkboxes is cumbersome on mobile. Can the logic for multiselect dropdowns by changed to AND?
Thank you!
January 4, 2019 at 11:24 am #20640Hi!
Well, there is no option there to change the logic, but with a custom code it might be possible. I will make sure to add a logic option for multi-select cases, it makes sense.
So, to resolve this, let’s try a custom code. Add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
Best,add_filter( 'asp_query_args', 'asp_and_logic_on_multiselect_cf', 10, 1 ); function asp_and_logic_on_multiselect_cf($args) { foreach ( $args['post_meta_filter'] as &$filter ) { if ( is_array($filter['value']) ) { $filter['logic'] = 'AND'; } } return $args; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.