Forums › Forums › Search & Filter Pro › Display search terms other than category do not work
Tagged: search terms
- This topic has 4 replies, 2 voices, and was last updated 8 years, 9 months ago by Ross.
-
Anonymous(Private) March 3, 2016 at 7:15 pm #38629
Hi!
I am using Avada theme.
I found some posts and this helpful link to know how to display search terms on Title bar:
https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/I added the following code:
global $searchandfilter;
$sf_current_query = $searchandfilter->get(8444)->current_query();
$sf_fields = $sf_current_query->get_fields_html(
array( “_sft_category”, “authors”, “post_date”)
);$title = sprintf( __( ‘Search results for: %s’, ‘Avada’ ), get_search_query() . ‘ ‘ . $sf_fields );
It works for Category, but not for the other fields I have in the searcg form as Athors and post_date range.
This is the page with the Advanced Search:
http://www.amiciperlacitta.it/news/la-bussola/ricerca-avanzata/
Can you help me?
Waiting for your kind replyRoss Moderator(Private) March 7, 2016 at 10:15 am #38801Have you tried to get the array of values:
?
Can you try to do this and do a
var_dump
of the result, and then past teh contents here?Thanks
Anonymous(Private) March 17, 2016 at 5:08 pm #39701Hi!
Sorry for my late reply but I had to complete another project..
If I do a var_dump I get the following:
array(2) { [“authors”]=> array(5) { [“name”]=> string(7) “Authors” [“singular_name”]=> string(6) “Author” [“all_items_label”]=> string(11) “All Authors” [“type”]=> string(9) “post_type” [“active_terms”]=> array(1) { [0]=> array(3) { [“id”]=> int(39) [“name”]=> string(7) “Agenzie” [“value”]=> string(7) “agenzie” } } } [“_sf_post_date”]=> array(1) { [“active_terms”]=> array(2) { [0]=> array(1) { [“value”]=> string(8) “01032016” } [1]=> array(1) { [“value”]=> string(8) “16032016” } } } }In my form I have Authors (in this example value for that is “Agenzie”) and Post Date range fields.
I am not expert in PHP…can you help me to get the authors and post date range?
As $sf_current_query->get_field_string(“authors”) does not work.Thanks
Anonymous(Private) March 17, 2016 at 5:54 pm #39703I finally found this solution:
$sarr = $sf_current_query->get_array();
$author = $sarr[authors][active_terms][0][name] ;
$fromDate = $sarr[_sf_post_date][active_terms][0][value] ;
$toDate = $sarr[_sf_post_date][active_terms][1][value];I hope it keeps on working always!
Ross Moderator(Private) March 17, 2016 at 11:50 pm #39736Thanks for the update, and glad you’ve got it working.
-
AuthorPosts