Forums › Forums › Search & Filter Pro › How to output the type of search done
Tagged: display, search type
- This topic has 5 replies, 2 voices, and was last updated 7 years, 11 months ago by Anonymous.
-
Anonymous(Private) December 4, 2016 at 2:28 pm #73929
Hi guys,
Looking for some help echoing the type of search done in my search.php file.
I have a search that uses “Sort Order” and it searches for posts four different ways – by date ascending and descending, and by two different custom values.
On my search page I wish to display a heading like “Results – Latest Posts” (eg for “Date Descending”) or “Results – Oldest Posts” (eg for “Date Descending”) …and so on for the other two searches.
How do I do this?
Many thanks,
Keith
Trevor(Private) December 4, 2016 at 5:25 pm #73958This thread will give you some ideas:
https://support.searchandfilter.com/forums/topic/how-to-get-post-meta-values/
Anonymous(Private) December 4, 2016 at 6:03 pm #73968Hey Trevor,
Thanks for the reply. However I’m not sure if what’s in that thread is exactly what I’m looking for..
Here’s my site below, the search is when you scroll down to “podcast episodes” and there’s a dropdown list named “view posts by:”)
When I conduct one of the different searches, here are the URLs..
http://lbl.pearldesign.ie/results-of-search/?sort_order=date+desc
http://lbl.pearldesign.ie/results-of-search/?sort_order=date+asc
http://lbl.pearldesign.ie/results-of-search/?sort_order=_sfm_featured-checkbox+desc+num
http://lbl.pearldesign.ie/results-of-search/?sort_order=_sfm_views+desc+numWhat I’m looking for is to be able to tap into the “sort order” values so that I simply output a heading for each different page which says something like “Results by: xxx” based upon what the “sort order” is.
Any ideas on how to do this? Not sure if what’s described on that thread is what I need (though could be wrong there..)
Keith
Anonymous(Private) December 4, 2016 at 6:26 pm #73970Hey Trevor,
Managed to figure it out.
For the record here’s what I used (replacing 725 with whatever your specific search ID is..)
<?php
global $searchandfilter;
$sf_current_query = $searchandfilter->get(725)->current_query();$array_data = $sf_current_query->get_array();
$typeOfSearch = $array_data[“_sf_sort_order”][“active_terms”][0][“value”];echo $typeOfSearch ;
?>
Keith
-
AuthorPosts