Forums Forums Search & Filter Pro Post Meta display current filter

Viewing 2 posts - 1 through 2 (of 2 total)
  • Anonymous
    #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
    #208462

    You 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.

Viewing 2 posts - 1 through 2 (of 2 total)