-
AuthorSearch Results
-
March 2, 2018 at 2:09 pm #163253
In reply to: How to make filter label appears in the search field
AnonymousInactiveHello,
In my search form UI I have a search form and multiple post meta acf checkbox
I tried :
<?php
global $searchandfilter;
$sf_current_query = $searchandfilter->get(53)->current_query();
echo $sf_current_query->get_search_term();
?>It display only search terms of the search form, not post meta acf checkbox one !
So I tried :
<?php
global $searchandfilter;
$sf_current_query = $searchandfilter->get(53)->current_query();
$args = array(
“str” => ‘%2$s’,
“delim” => array(“, “, ” – “),
“field_delim” => ‘, ‘,
“show_all_if_empty” => false
);echo $sf_current_query->get_fields_html(
array(“_sf_s”, “_sfm_nom-de-l-artiste”, “_sfm_prenom-du-commissaire”, “_sfm_lieu”, “_sfm_nom-du-medium”, “_sfm_forme-de-la-carte”, “_sfm_couleur”, “_sfm_ecole-du-commissaire”, “_sfm_jour-de-la-visite”, “_sfm_age-du-commissaire”),
$args
);
?>But it displays nothing !
Can you help me and telle me what I did wrong ?
Thank you very muche
Best regards,
JukeFebruary 26, 2018 at 10:41 am #162095In reply to: How to show Taxonomy title?
TrevorParticipantThis documentation may be what you are looking for (note, if you are using Ajax to refresh the page, any such output of the query needs to be inside the Ajax container):
https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/
There are many snippets also on this forum. Try this search:
https://support.searchandfilter.com/forums/search/current_query/
You need to fetch the values from the taxonomy form fields. Be aware that some search terms will be held as arrays, and not single strings/values.
February 21, 2018 at 9:11 am #161167In reply to: How to make filter label appears in the search field
TrevorParticipantWith some PHP coding on your part, yes you can display the query on the page. Note, if you are using Ajax to refresh the page, any such output of the query needs to be inside the Ajax container.
The documentation is here:
https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/
There are many snippets also on this forum. Try this search:
https://support.searchandfilter.com/forums/search/current_query/
You need to fetch the values from any form fields, and the search terms (they are held separately). The code to find and display taxonomies is different to that of custom fields, and be aware that some search terms will be held as arrays, and not single strings/values.
February 16, 2018 at 8:54 pm #160387In reply to: How to display active filters?
TrevorParticipantIs this what you are looking for?
https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/
There are many snippets in the forum as well. Do this search:
https://support.searchandfilter.com/forums/search/current_query/
And you will find quite a few useful threads.
February 14, 2018 at 5:52 pm #159710In reply to: Search not working or triggering my results layout
TrevorParticipantHi
Great to speak with you. Using your customised version of our results.php template file, you had excluded text searches and so needed to add a condition to check if they were being performed without using any of the other form controls, with:
$sf_current_query->get_search_term()==""
and
$sf_current_query->get_search_term()==!"
I will close this thread for now.
February 5, 2018 at 12:27 pm #157381In reply to: General search function not working
TrevorParticipantYou might need this for what is in the search box:
$search_words=$sf_current_query->get_search_term();
and then echo that. If you search our forum:
https://support.searchandfilter.com/forums/search/sf_current_query/
You will see many different examples of use.
February 5, 2018 at 12:11 pm #157375In reply to: General search function not working
AnonymousInactiveHi Trevor,
Thanks for the quick response.
I can get it to half work… This search query should yield the response:
“Search Results for: green Brexit, Legatum Institute, Posts”
http://smartthinking.staging.wpengine.com/?sfid=979&_sf_s=green&_sft_category=brexit&_sfm_think_tank=Legatum%20Institute&post_types=post#aAt least that is what I would like it to do. But currently only the category is showing.
This is the markup:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(979)->current_query(); ?> <h1 class="archive_title"><span><?php _e("Search Results for","wpbootstrap"); ?>:</span> <?php echo esc_attr(get_search_query()); ?> <?php $args = array( "str" => '%2$s', "delim" => array(", ", " - "), "field_delim" => ', ', "show_all_if_empty" => false ); echo $sf_current_query->get_fields_html( array("_sft_category", "_sft_post_tag", "_sft_sfdc_post_type", "_sft_sfdc_think_tank"), $args ); ?> </h1>
Have I done something wrong?
Thanks,
AlexJanuary 25, 2018 at 12:50 pm #154839In reply to: Alphabetise results and redirect empty search
TrevorParticipantRedirecting an empty search is not a feature of the pro plugin, as the plugin is far more complex.
It IS possible to use PHP to detect if a search has been made though, like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your VC template archive code/loop here }
January 24, 2018 at 8:57 pm #154736In reply to: Breadcrumbs Revisited – Hoping for Confirmation
AnonymousInactiveUnfortunately that’s a no-go. The complete code I put in (using your good chunk there) looked like:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(15)->current_query()->get_array(); echo '<strong>Filtered by:</strong>'; if ( is_empty($sf_current_query ) ) { echo "all"; } else { foreach($sf_current_query as $key) { echo ' • ' . $key['active_terms'][0]['name'] . ' '; } }?>
Am I missing something above if? Feels like that’s maybe where I’m off?
(The page does not display anything – no sidebar, no search form, so as-is above it pretty broken – did I close off the function properly?)January 24, 2018 at 8:41 pm #154721In reply to: Breadcrumbs Revisited – Hoping for Confirmation
TrevorParticipantIf the query is empty, the
$sf_current_query
array will be empty, so you can use the PHPempty()
function:if ( empty($sf_current_query ) ) { echo 'Nothing here folks.'; } else { .... }
I would think.
-
AuthorSearch Results