Forums › Forums › Search & Filter Pro › Post Meta display current filter
- This topic has 1 reply, 2 voices, and was last updated 5 years, 7 months ago by Trevor.
-
Anonymous(Private) April 15, 2019 at 4:21 pm #208435
Hi there,
I’d like to display the name of the active Post Meta filter. I’ll be using this to show a message when nothing in this type is available, e.g. “We currently have no “freelance” jobs available”.
I have to note that I’m not working with any taxonomies, but rather have a Post Meta filter which I grab from advanced custom field values (which works like a charm, love the support).
I tried this code but unfortunately nothing shows up:
<?php //Get a single fields values using labels //replace <code>1526</code> with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(1860)->current_query(); echo $sf_current_query->get_field_string("_sft_verhouding"); ?>
You can check the page out here. Please note it’s already sorted on “Alphahulp”
Trevor(Private) April 16, 2019 at 9:40 am #208462You can access the filter terms though, but would need further PHP work to display them. To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots of other data. If you have other filters, then it becomes a little more complex, but I can give you links. This thread might help you:
https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/
… and this search will give similar threads I think:
https://support.searchandfilter.com/forums/search/sf_current_query+get_array+field+%5Bvalue%5D/
Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.
-
AuthorPosts