Forums › Forums › Search & Filter Pro › Variable is not returned in title with the pro version
- This topic has 14 replies, 2 voices, and was last updated 4 years, 5 months ago by Trevor.
-
Anonymous(Private) July 6, 2020 at 8:26 am #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(Private) July 7, 2020 at 11:57 am #251679You 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?
Trevor(Private) July 7, 2020 at 12:18 pm #251704Ah, 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>
Trevor(Private) July 7, 2020 at 12:30 pm #251712More 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>
-
AuthorPosts