Forums › Forums › Search & Filter Pro › How to get Post Meta values?
Tagged: meta
- This topic has 8 replies, 2 voices, and was last updated 8 years ago by Trevor.
-
Anonymous(Private) November 28, 2016 at 9:00 pm #72711
Hello, is there any particular way to “get” the post meta values, similar to the way we can grab other search data?
For example:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(1526)->current_query(); $sf_current_query->get_search_term(); ?>
This lets us grab the current query’s search term. And custom taxonomy info can be grabbed through something like:
<?php $sf_current_query->get_taxonomy_terms_string('_sft_types'); ?>
However what would be the proper syntax to use to get various post meta data? (And more specifically when we have a numeric range set, those min and max values)
Thanks
Anonymous(Private) November 29, 2016 at 3:29 pm #72850Right, when someone runs a search they get to a page with a URL like:
http://example.com/results/?_sft_types=homes&_sfm_square-feet=3000+7500How can we grab the post meta value from that search, both the “3000” and the “7500” in that instance?
Trevor(Private) November 29, 2016 at 3:34 pm #72856Ah, OK. I understand. The data is there in an array, so the actual terms need will vary according to your form and the fields you have used. This thread may give you some ideas:
https://support.searchandfilter.com/forums/topic/how-to-style-the-search-data/
Anonymous(Private) November 30, 2016 at 5:43 pm #73321Hi, we were able to get the meta values we needed with get_array();
And for those curious the code we used was (square-feet is our custom field):
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(315)->current_query(); $array_data = $sf_current_query->get_array(); $squarefeet_min = $array_data["_sfm_square-feet"]["active_terms"][0]["value"]; $squarefeet_max = $array_data["_sfm_square-feet"]["active_terms"][1]["value"]; ?>
Thanks again for the help.
-
AuthorPosts