Forums › Forums › Search & Filter Pro › Results displayed: results count + searched tag + associated categories
Tagged: Results displayed code
- This topic has 3 replies, 2 voices, and was last updated 7 years, 10 months ago by Trevor.
-
Anonymous(Private) December 15, 2016 at 8:55 pm #76902
Dear support team,
I am looking for a PHP code to insert to show text displayed (only if it is filtered) on top of the results
Saying:
Results displayed: 1 – 10 of 21 for “tag” and “category or categories”and when the user clicks on the 2nd page of results it needs to show then
Results displayed: 11 – 20 of 21 for “tag” and “category or categories”Example of solution with a different plugin solved like this:
http://iztokostan.com/stanja/alergije/The version of the site with S&F PRO plugin, in a dev. mode i need the PHP code for:
http://iztokostan.com/testwpsubdomain/domov/?_sft_post_tag=alergijeI would need this really urgent as I want to change the filter plugin to S&F PRO on the clients site.
Trevor(Private) December 17, 2016 at 9:13 am #77226OK, nearly there. This is the code we have so far:
<?php global $searchandfilter; $sf_query = $searchandfilter->get(3217)->current_query(); if ($sf_query->is_filtered()) { ?> <div>Found <?php echo $sf_query->found_posts; ?> Results</div> <?php $sf_current_query = $searchandfilter->get(3217)->current_query()->get_array(); if (($sf_current_query['_sft_category']['active_terms'][0]['name'])<>"") echo "<div>KATEGORIJE: " . ($sf_current_query['_sft_category']['active_terms'][0]['name']) . "</div>"; if (($sf_current_query['_sft_post_tag']['active_terms'][0]['name'])<>"") echo "<div>OZNAKE: " . ($sf_current_query['_sft_post_tag']['active_terms'][0]['name']) . "</div>"; if (($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name'])<>"") echo "<div>KAKOVOST SPREMEMBE: " . ($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name']) . "</div>"; if (($sf_current_query['_sfm_starost']['active_terms'][0]['name'])<>"") echo "<div>STAROST: " . ($sf_current_query['_sfm_starost']['active_terms'][0]['name']) . "</div>"; if (($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name'])<>"") echo "<div>VRSTA PRIMERA: " . ($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name']) . "</div>"; } ?>
And we know that the only part NOT working is:
<div>Found <?php echo $sf_query->found_posts; ?> Results</div>
Trevor(Private) December 30, 2016 at 4:43 pm #79288Marjan, we seem to have successfully coded up the solution for this, using a PHP snippet:
<?php global $searchandfilter; $sf_query = $searchandfilter->get(3217)->current_query(); if ($sf_query->is_filtered()) { $sf_current_query = $searchandfilter->get(3217)->current_query()->get_array(); echo "<b>Prikaz rezultatov za...</b>"; $cat_string = ""; foreach($sf_current_query['_sft_category']['active_terms'] as $item) { $cat_string .= $item['name'] . ", "; } $starost_string = ""; foreach($sf_current_query['_sfm_starost']['active_terms'] as $item) { $starost_string .= $item['name'] . ", "; } if (($sf_current_query['_sft_category']['active_terms'][0]['name'])<>"") echo "<div>PRODUKTI: " . substr($cat_string, 0, -2) . "</div>"; if (($sf_current_query['_sft_post_tag']['active_terms'][0]['name'])<>"") echo "<div>STANJA: " . ($sf_current_query['_sft_post_tag']['active_terms'][0]['name']) . "</div>"; if (($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name'])<>"") echo "<div>KAKOVOST SPREMEMBE: " . ($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name']) . "</div>"; if (($sf_current_query['_sfm_starost']['active_terms'][0]['name'])<>"") echo "<div>STAROST: " . substr($starost_string, 0, -2) . "</div>"; if (($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name'])<>"") echo "<div>VRSTA PRIMERA: " . ($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name']) . "</div>"; } ?>
So I will close this now. Great to speak with you on Skype.
-
AuthorPosts