-
AuthorSearch Results
-
April 15, 2016 at 11:34 am #42840
In reply to: Start filter search with no preloaded results.
TrevorParticipantHi
It should look like this a bit, I think:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1726)->current_query(); if ($sf_current_query->is_filtered()) { // do the loop } else { // do something else }April 14, 2016 at 2:32 pm #42786In reply to: Start filter search with no preloaded results.
AnonymousInactiveThanks Trevor!
I am using a theme I started from underscores templateInstalled the results.php template and I am trying to use the github code here as reference.
but no luck yet..Any chance you can guide me a bit further?
Where do I place the following code in my results.php if it needs to be before the “have_posts” loop?
global $searchandfilter; $sf_current_query = $searchandfilter->get(1726)->current_query(); echo $sf_current_query->is_filtered();April 6, 2016 at 10:51 am #41768In reply to: Filter on EDD Search Results
RossKeymasterHi Adam
S&F doesn’t search tag names, nor does the default WP search – try your “Flowers” test with the old search and you will see (you can search tag names by combining S&F with Relevanssi).
RE the input box, thats the last step we missed!
So, each of the search input fields, that you have changed to be renamed to
_sf_s, also has avalueattribute.<input type="text" placeholder="<?php _e( 'Search', 'squarecode' ); ?>" value="<?php echo $searchresults; ?>" name="_sf_s" id="s" />we need to get the S&F search term into this value attribute. I can see in both your header and search templates, that the query is populated with the value from this line:
<?php $searchresults = get_search_query(); ?>So all we need to do is get S&F search query into that variable – from the docs you would replace the code above with –
<?php //Get the search term //replace <code>4243</code> with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(4243)->current_query(); $searchresults = $sf_current_query->get_search_term(); ?>Thanks
March 17, 2016 at 5:54 pm #39703In reply to: Display search terms other than category do not work
AnonymousInactiveI 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!
March 17, 2016 at 5:08 pm #39701In reply to: Display search terms other than category do not work
AnonymousInactiveHi!
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
February 17, 2016 at 7:05 pm #37243Topic: Display Sort Order?
in forum Search & Filter Pro
AnonymousInactiveHi, How would I display the sort order in a way similar to displaying categories or tags? Here’s the code I’m using, but only _sft_category and _sft_school display on my page.
$args = array( "str" => '<strong>%1$s</strong>: %2$s', "show_all_if_empty" => false //"field_delim" => '<hr />' ); echo $sf_current_query->get_fields_html(array("_sft_category", "_sft_school", "sort_order"), $args);Here’s a link to the test page:
http://staging.cudenvertoday.org/articlesThanks!
January 28, 2016 at 6:00 pm #35604In reply to: Display post meta from search field.
RossKeymasterwhat happens if you var_dump the array:
<?php //Get a single fields values using labels //replace 1526 with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(147)->current_query(); var_dump($sf_current_query->get_array()); ?>CAn you paste the output here?
Thanks
January 22, 2016 at 1:51 pm #34998In reply to: Display post meta from search field.
AnonymousInactiveWebsite is actually offline.
I just put in page template:
<?php
//Get a single fields values using labels
//replace 1526 with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(147)->current_query();
echo $sf_current_query->get_field_string(“_sfm_xxx”);?>
and Its echo nothing. I’m using ACF fileds
January 22, 2016 at 10:08 am #34979In reply to: Display post meta from search field.
AnonymousInactiveIm trying something like and its not working
<?php
//Get a single fields values using labels
//replace1526with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(147)->current_query();
echo $sf_current_query->get_field_string(“_sfm_xxx”);?>
Url looks like this:
http://www.xxx.com/?_sfm_xxx…January 19, 2016 at 12:11 pm #34656In reply to: Custom Search Results Page
RossKeymasterHi Scott
To answer your questions:
1) To get data from the current search you can use:
http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/So, from that link, the code would be
<?php //Get the search term //replace '1526' with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(1526)->current_query(); echo $sf_current_query->get_search_term(); ?>2) Which display method are you using? If you are using
archivethen it sounds like you have set your template up wrong (a little). This really depends on your theme, so go into your theme and take a look at other template files such asarchive.phporsearch.php.Usually you should at least be starting with a
get_header()and finishing with aget_footer()– but this is really theme dependent – https://codex.wordpress.org/Include_TagsThanks
-
AuthorSearch Results
-
Search Results
-
Topic: Display Sort Order?
Hi, How would I display the sort order in a way similar to displaying categories or tags? Here’s the code I’m using, but only _sft_category and _sft_school display on my page.
$args = array( "str" => '<strong>%1$s</strong>: %2$s', "show_all_if_empty" => false //"field_delim" => '<hr />' ); echo $sf_current_query->get_fields_html(array("_sft_category", "_sft_school", "sort_order"), $args);Here’s a link to the test page:
http://staging.cudenvertoday.org/articlesThanks!