Forums Forums Search & Filter Pro boolean custom field filtering not working

Tagged: 

Viewing 10 posts - 1 through 10 (of 13 total)
  • Anonymous
    #8912

    Hi,

    I’m a new customer of the pro version, and I can’t seem to get the post meta to filter correctly.

    I have a boolean custom field in my post (from advanced custom field) that can either take on 0 or 1. I’ve set the value in my posts, and through printing out the value using confirmed that indeed, this value is printing out as 0 or 1.

    When I try to filter on this value (using Post Meta), I observe some bizarre behavior.

    It seems to be recognizing and filtering on the 1 value just fine, but it does not filter at all on the 0 value (it lets all the 1 values through too, even though I checked that my post does indeed have a 0 value for that custom field). In addition, when I set the search operator to OR, and I select both 0 and 1, it says “no results found”.

    Thanks,
    Greg

    Ross Moderator
    #8923

    Hey there

    Sorry for the generic message – I got locked out and blacklisted by my host for this website!! – so been unable to login and reply to tickets – playing catchup now – will be systematically working through tickets today.

    Thanks

    Anonymous
    #8982

    Hi Ross,

    I’ve spent some time gathering a bit more information that I hope might be helpful in finding the solution.

    As I said above, I’m using the TRUE/FALSE field in Advanced Custom Fields. This assigns a key value of either 0 or 1.

    I then create a Search and Filter Pro filter for it (post meta) that has two values : 0 or 1, each with its own label.

    The “1” value works fine. It attaches a tag such as “?_sfm_key=1” to the url.

    The “0” value, when selected in the form (i’m using a checkbox), does nothing to the URL.

    *However*, when I manually enter “?_sfm_key=0” into the URL, the filter executes as expected.

    So, somehow, it appears that the checkbox in the form is not attaching the proper query to the URL when the value is 0…is there perhaps a special case being handled for a 0 value?

    Thanks,
    Greg

    Ross Moderator
    #9032

    Hey Greg

    You’re absolutely spot on with that actually – for many fields such as taxonomy, I always manually add an option such as “All Categories” and I use the value of “0” to handle this easily.

    I realise now, in your case with the Custom Fields that “0” really is not suitable any more and maybe some special processing going on to ignore that field.

    Do you have a working link I could look at?

    Thanks

    Anonymous
    #9043

    Sure, thanks for your help! The link is here:

    http://dev.graceatworkllc.com/calvary/sermons-archive/

    THe category in question is the “sermons” and “sunday schools”. Sunday schools is mapped to 1 and works, sermons is mapped to false (0) and doesn’t work.

    Unfortunately, in advanced custom fields, i dont’ think for the true/false type there’s way to map to any value other than 0 or 1…

    just a suggestion, but would is_numeric be a good way to handle the “all catgories” case?

    Upon reflection, I guess what I really want is for the boxes to be checked by default, and then people can uncheck to remove one category or another … is this possible too?

    Thanks,
    Greg

    Anonymous
    #9132

    Hey Ross,

    Just wondering if you had a chance to look into this issue?

    Actually, I took back what I said at the end of the last email…I don’t need all the checkboxes checked by default…don’t know what I was thinking 🙂

    But any idea how to get the 0 field to work for true/false types?

    Thanks,
    Greg

    Ross Moderator
    #9162

    Hey again!

    I’m going to have to make some modification to the plugin to fix the boolean support – once I’ve done that we can have a look at the rest – however there is currently no way to set defaults for the search form.

    Thanks

    Anonymous
    #9168

    Thanks Ross … can you please give me an idea of the timescale for this fix (hours / days / months) so that I can decide whether I need to look for another solution in the interim so we can launch?

    Thanks!
    Greg

    Anonymous
    #9290

    Hey Ross,

    Just wondering if you have any updates on this?

    Thanks!
    Greg

    Ross Moderator
    #9313

    I’ve managed to fix this and will be available in next update (tomorrow providing testing goes well).. 🙂

Viewing 10 posts - 1 through 10 (of 13 total)