Forums Forums Search & Filter Pro How to make filter label appears in the search field

Viewing 10 posts - 1 through 10 (of 12 total)
  • Anonymous
    #161145

    Hello,

    I use a search field and several checkbox to filter my posts and when I check one or several checkbox I would like the checkbox labels appears in the search field.
    It’s possible to make it appears in the URL like in your demo (http://demo.designsandcode.com) but I want it in the search field.

    Can you help me ?

    Thank you,
    Best regards
    Juke

    Trevor
    #161148

    I am sorry, but this is not a feature of our plugin. It appears in the URL because this is the search query string sent to the results page.

    Anonymous
    #161160

    OK Thank you,

    And is it possible to make it appears somewhere else than in the URL ?
    Somthing like : Filter 1 + Filter 2 + Filter 3

    Regards,
    Juke

    Trevor
    #161167

    With some PHP coding on your part, yes you can display the query on the page. Note, if you are using Ajax to refresh the page, any such output of the query needs to be inside the Ajax container.

    The documentation is here:

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

    There are many snippets also on this forum. Try this search:

    https://support.searchandfilter.com/forums/search/current_query/

    You need to fetch the values from any form fields, and the search terms (they are held separately). The code to find and display taxonomies is different to that of custom fields, and be aware that some search terms will be held as arrays, and not single strings/values.

    Anonymous
    #161175

    Thank you I’ll take a look !

    Anonymous
    #163253

    Hello,

    In my search form UI I have a search form and multiple post meta acf checkbox

    I tried :

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(53)->current_query();
    echo $sf_current_query->get_search_term();
    ?>

    It display only search terms of the search form, not post meta acf checkbox one !

    So I tried :

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(53)->current_query();
    $args = array(
    “str” => ‘%2$s’,
    “delim” => array(“, “, ” – “),
    “field_delim” => ‘, ‘,
    “show_all_if_empty” => false
    );

    echo $sf_current_query->get_fields_html(
    array(“_sf_s”, “_sfm_nom-de-l-artiste”, “_sfm_prenom-du-commissaire”, “_sfm_lieu”, “_sfm_nom-du-medium”, “_sfm_forme-de-la-carte”, “_sfm_couleur”, “_sfm_ecole-du-commissaire”, “_sfm_jour-de-la-visite”, “_sfm_age-du-commissaire”),
    $args
    );
    ?>

    But it displays nothing !

    Can you help me and telle me what I did wrong ?

    Thank you very muche
    Best regards,
    Juke

    Trevor
    #163328

    I am not sure, but a good place to start is to echo the entire query array to the screen so you can see what everything is. Like this:

    $sf_current_query = $searchandfilter->get(53)->current_query();
    echo '<pre>';
    print_r($sf_current_query->get_array());
    echo '</pre>';
    Anonymous
    #163335

    Thank you ! Yes you’re right it displays the entire query ! How to keep only all the [value] results ?

    Array
    (
    [_sfm_prenom-du-commissaire] => Array
    (
    [name] =>
    [singular_name] =>
    [all_items_label] =>
    [type] => post_meta
    [active_terms] => Array
    (
    [0] => Array
    (
    [name] => Anaëlle T.
    [value] => Anaëlle T.
    )

    )

    )

    [_sfm_jour-de-la-visite] => Array
    (
    [name] =>
    [singular_name] =>
    [all_items_label] =>
    [type] => post_meta
    [active_terms] => Array
    (
    [0] => Array
    (
    [name] => Jeudi
    [value] => Jeudi
    )

    [1] => Array
    (
    [name] => Lundi
    [value] => Lundi
    )

    )

    )

    )

    Trevor
    #163345

    Now that you know the hierarchy of each, you should be able to modify your original code to show what you want by referring to the array elements that you can now see.

    Anonymous
    #163438

    Yes you’re right but I’m not really a php developper and I really don’t know what I should do ! Can you give me a track, please !

    Big thank you
    Juke

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