-
Search Results
-
Hi, I need to display posts count next to labels, cant find it anywhere in this query.
global $searchandfilter;
$sf_current_query = $searchandfilter->get(XXXX)->current_query();
var_dump($sf_current_query->get_array());what should I do in order to achieve this?
thanx
Topic: Getting updated search term
Hi Ross,
I’m still having an issue with getting the (new) search term when someone starts a new search from the search results page filters. As part of the filter setup on the results page, there is a search box to ‘start a new search’ if the site visitor isn’t seeing the results they want.
However, when they search on a new phrase, the new search term is reflected in the URL and the results, but not in the text at the top of the page that says “Search Results for [search term]”.
I posted about this previously here:
https://support.searchandfilter.com/forums/topic/search-variable-s-versus-_sf_s/And I did add the suggested code to my template (search-deals.php), which to the best of my recollection was working fine then, or if not I may not have tested adequately to notice.
The odd thing is that if I refresh (reload) the page of search results, then it updates the verbiage and is correct, but if I just enter a new search term and hit enter, then the page isn’t actually being reloaded, so the verbiage doesn’t change.
SO my sequence is this: On the home page I have a S&F Pro search box (no filters, just a search box) and it’s set to display results on search-deals.php. On that template is called the results page filter, which lets visitors filter their results and that filter includes a(nother) search box to start a new search if they want to. That Filter is also set to display results on search-deals.php.
SO on search-deals.php I have the following code:
<?php $search_term = ""; //get global S&F object global $searchandfilter; $current_query = $searchandfilter->get(725)->current_query(); //(NOTE 725 is the ID of my search results page filter) //check to see if a term has been found under the regular WP variable //if not, try the S&F object if(get_search_query()!="") { $search_term = get_search_query(); } else if($current_query->get_search_term()!="") { $search_term = $current_query->get_search_term(); } ?> <header class="entry-header"> <h2 class="entry-title"><?php printf( esc_html__( 'Search Results for: %s', 'quark' ), '<span>“' . $search_term . '”</span>' ); ?></h2> </header>The problem is with the last bit – the header that write to the page the “search results for: %s” – I’m not sure how to *replace* the original search term for the new one as ‘%s’ even though the page URL is updated fine and the results are updated and correct for the new search term.
I hope this makes sense!
As always thanks for your wonderful support! 🙂
Topic: Trouble with get_fields_html
I’m trying to output the filtered data using your instructions on the Accessing the Search Data page (http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/). However, the outputted field names and respective data are not wrapped in any sort of html tag.
I would like the output to look something like this:
<div class=”filterdata”>
<div class=”fieldname”>Categories:</div>
<div class=”fielddata”>Community<br/>Arts</div>
</div>Is that possible by manipulating the sf_current_query?