-
AuthorSearch Results
-
February 3, 2019 at 11:12 am #201022
In reply to: How to display Taxonomy in Search Results.php?
TrevorParticipantHi
There is a code back tick on most keyboards; use that once before and once after the code you post. On my keyboard it is the key to the left of the 1 key.
As to fetching the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lost 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/
January 17, 2019 at 1:47 pm #199219
TrevorParticipantYou are not using our integration guide for Elementor?
https://searchandfilter.com/documentation/3rd-party/elementor/
The https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lost 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 that (as far as I know) you cannot run PHP in Elementor elements. It has to be inside a PHP template, or inside a shortcode that can run PHP (there are such plugins out there that let you make shortocdes that use PHP).
January 17, 2019 at 12:32 pm #199207
AnonymousInactiveHello,
I have s&f pro on elementor and I like to show the tags/cats of the filtered results.
I found this page: https://searchandfilter.com/documentation/accessing-search-data/
But the PHP string is not working on my page, I just see a part of the string where I would like to have the meta of the filtered posts.Used this code and put it in a text and html field, both same results:
<?php
//grab the active query from our search form
//replace1526with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(REPLACED WITH S&F ID)->current_query();?>
January 8, 2019 at 2:37 pm #198357In reply to: Cannot filter on custom wp post
AnonymousInactiveWell I might have asked wrong way 🙂
The thing is the filter as I call it with the shortcode shows up, but if I try to filter results (e.g. I select one region in the dropdown or white a text to the search input and press submit), nothing changes – the result set of $trainers remains unchanged (unfiltered), so as the $GLOBALS[‘wp_query’]->request).
From your first link you provided, I tried this code:
$sf_current_query = $searchandfilter->get(1513)->current_query(); echo '<pre>'; print_r($sf_current_query->get_array()); echo '</pre>';and got
array (size=10) 'paged' => int 1 'search_filter_id' => int 1513 'search_filter_override' => boolean false 'posts_per_page' => int 10 'post_status' => array (size=1) 0 => string 'publish' (length=7) 'meta_query' => array (size=0) empty 'post_type' => string 'trainer' (length=7) 'is_search' => boolean true 'is_archive' => boolean true 'post__in' => array (size=7) 0 => int 1284 1 => int 1495 2 => int 1503 3 => int 1504 4 => int 1505 5 => int 1506 6 => int 1508(notice there is no sign of filtering in the array). This is my main problem.
January 8, 2019 at 2:27 pm #198353In reply to: Cannot filter on custom wp post
TrevorParticipantAh, I see. I misunderstood your initial question. I am sorry for that. At least, I think I understand.
Showing the word searched for is not so difficult. If you have other filters, then it becomes a little more complex, but I can give you links. The documentation page:
https://searchandfilter.com/documentation/accessing-search-data/
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/
December 11, 2018 at 4:20 pm #195947In reply to: Start with no results
TrevorParticipantAh, you would need to code it in your PHP template then, much like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1033)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your template archive code here }December 11, 2018 at 3:23 pm #195909In reply to: Results initially added via AJAX
TrevorParticipantThis 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/
December 11, 2018 at 12:57 pm #195882In reply to: Results initially added via AJAX
AnonymousInactiveHey,
I’m using PHP, so if this is the query:
$sf_current_query = $searchandfilter->get(1033)->current_query();Once I have $sf_current_query how do I feed that into wp_query to return a specific set of results?
Thanks,
DanNovember 9, 2018 at 3:36 pm #193405In reply to: Show relationship ACF field in results
TrevorParticipantYes, like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(12204)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your template archive code/loop OR results.php code here }October 31, 2018 at 6:14 pm #192425In reply to: Checkboxen uncheck after ajax refresh
AnonymousInactiveThanks for the links about this subject and great to hear about this option coming to the plugin in 2019.
In this guide: https://searchandfilter.com/documentation/accessing-search-data/
I have to use a code and replace it with the form-id. But I have 9 different forms, using the same page-template, who are switched on and off by some widget logic.
Is their a possibility to use this code and let the code search for the right for id who is active on the page the user is visiting?:<?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(1526)->current_query(); echo $sf_current_query->get_field_string("_sft_category"); ?> -
AuthorSearch Results
-
Search Results
-
Hello,
I have s&f pro on elementor and I like to show the tags/cats of the filtered results.
I found this page: https://searchandfilter.com/documentation/accessing-search-data/
But the PHP string is not working on my page, I just see a part of the string where I would like to have the meta of the filtered posts.Used this code and put it in a text and html field, both same results:
<?php
//grab the active query from our search form
//replace1526with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(REPLACED WITH S&F ID)->current_query();?>