Forums Forums Search & Filter Pro Variable is not returned in title with the pro version

Viewing 10 posts - 1 through 10 (of 15 total)
  • Anonymous
    #251416

    Hi ! I come back to you because there is a bug : the variable of the search is not displayed in the pgae result like but that worked with the S&L freemium.

    The code in my theme search.php : <h1 class=”page-title”><?php printf( esc_html__( ‘Résultats de la recherche pour : %s’, ‘zikzag’ ), ‘<span>’ .get_search_query(). ‘</span>’ ); ?></h1>

    The ” %s ” is not returned..

    Thanks for your help

    Trevor
    #251482

    The equiavlent variable name for our pro plugin is _sf_s.

    For some users, that works. Otherwise, the coding will be to change what you have by first fetching the search stong, then echoing. But, try changing %s to %_sf_s and let me know?

    Anonymous
    #251652
    This reply has been marked as private.
    Trevor
    #251679

    You will need to replace 1234 with your form ID.

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1234)->current_query();
    $search_term = $sf_current_query->get_search_term();
    ?>
    <header class="searсh-header">
    <h1 class="page-title">Résultats de la recherche : <span><?php echo $search_term;?></span></h1></header>

    See if that works?

    Anonymous
    #251698

    I’m sorry, that does not work, no keywork string returning.

    Trevor
    #251704

    Ah, sorry, I just realized, you want the category to show, NOT the search term?

    That may be a little more complex. This MIGHT work:

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1234)->current_query();
    $search_cat = $sf_current_query->get_field_string("_sft_category");
    ?>
    <header class="searсh-header">
    <h1 class="page-title">Résultats de la recherche : <span><?php echo $search_cat;?></span></h1></header>
    Anonymous
    #251708

    Ok Trevor, there is something displayed but it’s not good :

    “Résultats de la recherche : Catégories: Toutes

    In english –> Catégories: Toutes = Category: all

    Trevor
    #251712

    More complex is needed then.

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1234)->current_query()->get_array();
    $search_cat = $sf_current_query['_sft_category']['active_terms'][0]['name'];
    ?>
    <header class="searсh-header">
    <h1 class="page-title">Résultats de la recherche : <span><?php echo $search_cat;?></span></h1></header>
    Anonymous
    #251721

    nothing is displayed again..

    Trevor
    #251725
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 15 total)