Forums › Forums › Search & Filter Pro › displaying a search counter
- This topic has 5 replies, 2 voices, and was last updated 7 years, 10 months ago by Trevor.
-
Anonymous(Private) January 6, 2017 at 3:54 pm #80549
HI,
I am trying to display a search counter but am coming across a glitch.
<h3 class="pagetitle">Search for <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' — '); echo $count . ' '; _e('resources'); wp_reset_query(); ?></h3>
is the code I am using at the top of the results page.
This works but then seems to conflict with the search and filter results. So if I search for ‘easter’ in ‘Category A’ it comes back with:
“Search for easter — 13 resources”
then, if I change this search to ‘Category B’, it says the same again:
“Search for easter — 13 resources”
… though there are no ‘easter’ posts in ‘Category B’ and no results are shown.
So the search and filter part is working fine (showing no results) but the ‘search count’ I have added seems to want to display all of them.
I guess what I am really trying to say is what is the correct method to get a search count on my results page!
: )
Thanks!
Anonymous(Private) January 6, 2017 at 5:28 pm #80564Hi Trevor, thanks for getting back to me.
I think displaying the true number of results is a definate addition that needs to be made to the plugin, its a basic and fundamental part of search results. Please can you let me know when something is sorted for this? Or let me know how I can find out?
I notice there is a working post counter on the demo here:
http://demo.designsandcode.com/sfpro-woo-mystile/shop/
how was that acheieved?
-
AuthorPosts