-
AuthorSearch Results
-
March 5, 2019 at 11:59 am #203951
In reply to: Hide results by default
TrevorParticipantThe hide results code is like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(36613)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your current results.php code here }… where the ID number will need to be changed to match your form ID
February 13, 2019 at 2:53 pm #202121In reply to: results display
TrevorParticipantIf you are using our Shortcode Display Results method, then the results.php needs to be modified like this (where the ID number will need to be changed to match your form ID):
global $searchandfilter; $sf_current_query = $searchandfilter->get(36613)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your current results.php code here }If using other methods, and if you have access to the template PHP files, you could use similar code.
Make sure any files you modify are in the child theme folder (if you copy our results.php file, it needs to be in a sub-folder of the child theme, called
search-filter, not our plugin folder or a parent theme folder).February 6, 2019 at 8:08 am #201347In reply to: Current menu item
TrevorParticipantYes, that is totally possible. You need to edit the results.php template file you are using, like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(36613)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your current results.php code here }February 3, 2019 at 11:12 am #201022In 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/
-
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();?>