Display search terms other than category do not work

Forums Forums Search & Filter Pro Display search terms other than category do not work

Tagged: 

Viewing 5 posts – 1 through 5 (of 5 total)
  • Anonymous
    #38629

    Hi!
    I am using Avada theme.
    I found some posts and this helpful link to know how to display search terms on Title bar:
    https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/

    I added the following code:
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(8444)->current_query();
    $sf_fields = $sf_current_query->get_fields_html(
    array( “_sft_category”, “authors”, “post_date”)
    );

    $title = sprintf( __( ‘Search results for: %s’, ‘Avada’ ), get_search_query() . ‘ ‘ . $sf_fields );

    It works for Category, but not for the other fields I have in the searcg form as Athors and post_date range.
    This is the page with the Advanced Search:
    http://www.amiciperlacitta.it/news/la-bussola/ricerca-avanzata/
    Can you help me?
    Waiting for your kind reply

    Ross Moderator
    #38801

    Have you tried to get the array of values:

    https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/#Getan_array_offilterswithvalues_and_labels

    ?

    Can you try to do this and do a var_dump of the result, and then past teh contents here?

    Thanks

    Anonymous
    #39701

    Hi!
    Sorry for my late reply but I had to complete another project..
    If I do a var_dump I get the following:
    array(2) { [“authors”]=> array(5) { [“name”]=> string(7) “Authors” [“singular_name”]=> string(6) “Author” [“all_items_label”]=> string(11) “All Authors” [“type”]=> string(9) “post_type” [“active_terms”]=> array(1) { [0]=> array(3) { [“id”]=> int(39) [“name”]=> string(7) “Agenzie” [“value”]=> string(7) “agenzie” } } } [“_sf_post_date”]=> array(1) { [“active_terms”]=> array(2) { [0]=> array(1) { [“value”]=> string(8) “01032016” } [1]=> array(1) { [“value”]=> string(8) “16032016” } } } }

    In my form I have Authors (in this example value for that is “Agenzie”) and Post Date range fields.
    I am not expert in PHP…can you help me to get the authors and post date range?
    As $sf_current_query->get_field_string(“authors”) does not work.

    Thanks

    Anonymous
    #39703

    I finally found this solution:

    $sarr = $sf_current_query->get_array();

    $author = $sarr[authors][active_terms][0][name] ;
    $fromDate = $sarr[_sf_post_date][active_terms][0][value] ;
    $toDate = $sarr[_sf_post_date][active_terms][1][value];

    I hope it keeps on working always!

    Ross Moderator
    #39736

    Thanks for the update, and glad you’ve got it working.

Viewing 5 posts – 1 through 5 (of 5 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.