-
AuthorSearch Results
-
April 25, 2019 at 4:22 pm #209339
In reply to: How to display filtered results count and filters?
AnonymousInactiveThank you so much. Now Im displaying the result counter also Im displaying the filters.
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(840)->current_query(); $args = array( "str" => '%2$s', "delim" => array(", ", " - "), "field_delim" => ', ', "show_all_if_empty" => false ); echo $sf_current_query->get_fields_html( array("_sft_category"), $args ); ?>
My result is
Genre1, Genre2, Genre3, etc…
How I can “put” this array in div or class?
April 25, 2019 at 4:01 pm #209333In reply to: How to display filtered results count and filters?
TrevorParticipantI am sorry for the delay. I am working my way through a backlog and I answer posts is oldest last touched order, so yours was still another two or three down the list when you sent that last reply. The standard WordPress would, with your wp_query() array name, look like this:
Found <?php echo $query_all->found_posts; ?> Results
As to showing the filters, this is more complex. It would require custom coding when using the current version of Search & Filter Pro. You can access the filter terms though, but would need further PHP work to display them. To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots 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, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.
April 25, 2019 at 2:07 pm #209306In reply to: Display selected filters
TrevorParticipantIt would require custom coding when using the current version of Search & Filter Pro. You can access the filter terms though, but would need further PHP work to display them. To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots 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, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.
April 16, 2019 at 9:40 am #208462In reply to: Post Meta display current filter
TrevorParticipantYou can access the filter terms though, but would need further PHP work to display them. To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots 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, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.
April 15, 2019 at 11:44 pm #208449In reply to: show results only after clicking search
AnonymousInactiveHere I have to add something, I have several pages and in each one I use a different personalized filter, each page corresponds to a department of Colombia, therefore, what we are looking for, is that the search result only brings results from that department, that’s why, if you go to the next two pages, you can see that the filter results are different.
https://www.starpets.com.co/antioquia/
https://www.starpets.com.co/cundinamarca/This I clarify, since after reviewing the help forum, I found this answer that you gave previously to a user https://support.searchandfilter.com/forums/topic/prevent-empty-search-fetching-results/#post -185868 but I do not know if it applies to my project, since here you indicate that you should replace the id of the page, but if there are several forms and each one has a different id, how can I achieve what you indicate?
and so the code of my results.php file is displayed:
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link https://searchandfilter.com * @copyright 2018 Search & Filter * * Note: these templates are not full page templates, rather * just an encaspulation of the your results loop which should * be inserted in to other pages by using a shortcode – think * of it as a template part * * This template is an absolute base example showing you what * you can do, for more customisation see the WordPress docs * and using template tags – * * http://codex.wordpress.org/Template_Tags * */ if ( $query->have_posts() ) { ?> Found <?php echo $query->found_posts; ?> Results<br /> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> <div class="pagination"> <div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div> <?php while ($query->have_posts()) { $query->the_post(); ?> <div> <h2>"><?php the_title(); ?></h2> <p><br /><?php the_excerpt(); ?></p> <?php if ( has_post_thumbnail() ) { echo '<p>'; the_post_thumbnail("small"); echo '</p>'; } ?> <p><?php the_category(); ?></p> <p><?php the_tags(); ?></p> <p><small><?php the_date(); ?></small></p> </div> <hr /> <?php } ?> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> <div class="pagination"> <div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div> <?php } else { echo "No Results Found"; } ?>
I do not know if there is something wrong here too, because in the page where I’m trying to find the code, at the end of the results, this comes out:
global $searchandfilter; $sf_current_query = $searchandfilter->get(2101)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()==””)) { echo ‘
Nothing to see here folks!
‘; } else { // your template archive code/loop OR results.php code here }April 15, 2019 at 4:21 pm #208435Topic: Post Meta display current filter
in forum Search & Filter Pro
AnonymousInactiveHi there,
I’d like to display the name of the active Post Meta filter. I’ll be using this to show a message when nothing in this type is available, e.g. “We currently have no “freelance” jobs available”.
I have to note that I’m not working with any taxonomies, but rather have a Post Meta filter which I grab from advanced custom field values (which works like a charm, love the support).
I tried this code but unfortunately nothing shows up:
<?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(1860)->current_query(); echo $sf_current_query->get_field_string("_sft_verhouding"); ?>
You can check the page out here. Please note it’s already sorted on “Alphahulp”
March 30, 2019 at 3:42 pm #207000In reply to: No Results – DateTime Range
AnonymousInactiveI’ve made some progress with this.
I can alter the query by adjusting the meta_query as above but I need to remove a fields value from $sf_current_query. When I unset it the query is still run like it’s there.
I removed it like this
unset($sf_current_query['_sfm__audiotheme_gig_datetime']);
March 29, 2019 at 4:56 pm #206924In reply to: Hook to display number of filtered results?
TrevorParticipantThere is not, sorry. You can access the filter terms though, but would need further PHP work to display them. To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots 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, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.
March 11, 2019 at 1:55 pm #204644In reply to: no terms are showing in dropdown fields
TrevorParticipantTo hide first results.
You now have a block of code in the results.php file (Ignoring the initial comments).
You need to add/wrap some code around the code you have, 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
March 7, 2019 at 3:33 pm #204268
TrevorParticipantThe basic PHP for a ‘blank’ before search page is this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(36613)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { // just your search form here } else { // your current template code here }
… where the ID number will need to be changed to match your form ID.
-
AuthorSearch Results
-
Search Results
-
Hi there,
I’d like to display the name of the active Post Meta filter. I’ll be using this to show a message when nothing in this type is available, e.g. “We currently have no “freelance” jobs available”.
I have to note that I’m not working with any taxonomies, but rather have a Post Meta filter which I grab from advanced custom field values (which works like a charm, love the support).
I tried this code but unfortunately nothing shows up:
<?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(1860)->current_query(); echo $sf_current_query->get_field_string("_sft_verhouding"); ?>
You can check the page out here. Please note it’s already sorted on “Alphahulp”