Accessing the Search Data

Forums › Forums › Search & Filter Pro › Accessing the Search Data

Viewing 9 posts – 1 through 9 (of 9 total)
  • Anonymous
    #95951

    Hello,
    when I try to output currently selected filter values, this is working:

    echo $sf_current_query->get_field_string(“_sfm_category”);

    But this is not working, as well as any filter that start with _sfm:
    echo $sf_current_query->get_field_string(“_sfm_character”);

    What can be reason?

    Anonymous
    #95952
    This reply has been marked as private.
    Trevor
    #95968

    Do you mean echo $sf_current_query->get_field_string("_sft_category"); with a t and not an m?

    Does the guidance and examples in the documentation help?

    Anonymous
    #95973

    Sorry for the mistake, I mean echo $sf_current_query->get_field_string("_sft_category"); with t

    I did things as in the documentation, but cant output any _sfm filters

    Anonymous
    #95975

    I found some workaround, to display currently selected value:

    $tmp = $sf_current_query->get_array();
    echo $tmp["_sfm_character"]["active_terms"][0]["name"];
    

    But it may be a bug in get_field_string method from documentation, which is not working in my case:

    echo $sf_current_query->get_field_string("_sfm_character");

    Trevor
    #95979

    category is obviously a taxonomy, but is character a custom field?

    Anonymous
    #95984

    character is a custom field in custom type, created with ACF.
    In the search form settings, this is a “post meta” field

    Trevor
    #95997

    Custom fields, because of their variable data content and types, are returned as arrays, hence the examples in the documentation.

    Taxonomies always return strings. If you have set the form element for a taxonomy to have a single choice, it will be a string that is returned, if you have set it for multi-choice, then it would return an array.

    Does that explain why what you tired worked for one field in the form and not the other?

    Anonymous
    #98546

    Thank you for your assistance, I am not sure that I understood how it works, but anyway I managed to reach all the data with arrays, it always work, so no problem.
    We can close that topic.

Viewing 9 posts – 1 through 9 (of 9 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.