Forums › Forums › Search & Filter Pro › Problem with filter logic
- This topic has 16 replies, 2 voices, and was last updated 9 years, 3 months ago by
Anonymous.
-
Anonymous(Private) December 7, 2015 at 12:39 pm #31601
Hi
I have a difficulty with choosing the right logic for filtering.
I use Advanced Custom Fields to add some details to my posts (actually PDF downloads).
Say I have a “Needed stuff” multi-select custom field. Post 1 has value A. Post 2 has value B. Post 3 has value A and B.When filtering (using checkboxes or multi-select), I need this to happen:
– if value A checked/selected, display post 1,
– if value B checked/selected, display post 2,
– if values A and B checked/selected, display post 1, 2 and 3.You will easily understand my need: a post with 2 values should not be displayed in results if both values were not checked in the form.
Currently, whatever logic I try, it doesn’t work. What have I missed? Isn’t your PRO plugin able to do the trick?
Thank you for the help.Ross Moderator(Private) December 8, 2015 at 12:16 pm #31684Sure, under the “General” tab you must choose the field relationship “OR”.
If this is still not working, then you might be using two meta fields, with the same meta key?
If so then you will need to read the limitations here:
You must use separate custom fields for each unique field in S&F.
Thanks
Anonymous(Private) December 8, 2015 at 1:03 pm #31702Nope, it doesn’t work as I need.
For example, selecting option A show Posts with value A and Posts with value A+B. In my need, it should only show Post with value A.
Posts with value A+B should only be displayed if Options A and option B are selected.More info in private below.
Anonymous(Private) December 9, 2015 at 10:27 am #31806I must reformulate my problem.
Using OR operator in the checkbox, the logic is good if I select value A and value B: it shows posts A, posts B, and posts A+B.
OKBut the problem remains. If I select only value A, posts with value A are visible (good), but posts with value A+B display too. This last part is what bugs me. I can understand the logic behind: the filter displays posts that have the selected value, but the filter doesn’t take into account the other values of the posts.
Actually, whatever operator I set, selecting 1 value will also show posts with multiple values, as long as any one of those values is the one selected.
What I need is the contrary: a post is displayed only if each and every of its values (post-meta) is selected.Right now, I don’t find a method to do that with your PRO plugin. But there should be a way to do it, right? :s
Ross Moderator(Private) December 14, 2015 at 9:07 am #32133Hi Julien
I think I follow your logic.
When you select “A”, then all posts that have value “A” assigned to them are returned, even if they have multiple values.
The same for “B” – which is why we see the one with “A & B” show up on either selection.
What you want is so that selecting A, or selecting B does not show “A & B”? what would happen when you select A and select B, do you see all 3 options? or would you only see the result “A & B”?
Eitehr way, I’m afraid this not how the logic works in S&F.
When people search for things, lets say in a different scenario, like a shop, and they select “L” for large, they want to see all results that have size large, not ONLY and exclusively size large.
This kind of logic applies to most scenarios too, lets say a gallery, or a blog when a user is choosing a category – they don’t want to see only posts exclusive to that category, they want to see see any post in that category.
I’m just explaining this because this is the first time in over 2 years there has been a request for this kind of logic.
Its an interesting use case – could you explain why you require this kind of logic (just to help me understand and see if its a potential feature to add in to Search & Filter)?
Thanks
Anonymous(Private) December 14, 2015 at 1:17 pm #32158Hi Ross
Thanks for getting back to me.what would happen when you select A and select B, do you see all 3 options?
Yes. A posts, B posts, and A+B posts.
This kind of logic applies to most scenarios too, lets say a gallery, or a blog when a user is choosing a category – they don’t want to see only posts exclusive to that category, they want to see see any post in that category.
As a user (and not only a webdesigner), I must disagree. If a website has a lot of items and I am looking for something specific, I use the filter precisely, and sometimes, on websites I visit, those filters are kind of useless because the more I check criteria, the more items are shown, whereas I need my search to be more precise, not less.
But I totaly agree it has to be an option, not a default behaviour (and it’s not exactly the scenario in which I am). I guess that is the exact same reason why you offer to choose between OR and AND operators.
It’s an interesting use case – could you explain why you require this kind of logic (just to help me understand and see if its a potential feature to add in to Search & Filter)?
Sure. As I pointed you in a previous private post, here is exactly what I need: http://zombicide.com/en/free-missions
The user selects the game boxes he/she owns, and the filter shows the missions he/she can play (see how the colors of the blood spots match the boxes color).
If I own blue box and green box, missions will show if they need blue box, green box, or both.
But if I only have green box, missions that need blue and green won’t show.
If I add red box to green box, red missions and red+green will show (besides green missions).I really don’t think such need is that rare. Currently, I found no plugin that offer this feature, probably because it is more complicated (needs checking if every criteria is matched, and not just if any criteria is present).
It may need to count the number of criteria, or maybe create special criteria combinations. I am not sure (and I am no developper, though I made this work on previous website with javascipt on a static site, but it is harder in a WP environment).You will decide if it is worth working on this feature for your plugin (my opinion is biased). If you decide against it, I will probably not use your plugin. But if you want to give it a try, I will be glad to help in any way I can (and I think it may be a plus feature for your plugin compared to what others offer 😉 )
Please don’t hesitate to contact me in private.
-
AuthorPosts