-
AuthorSearch Results
-
October 31, 2018 at 5:53 pm #192423
In reply to: Checkboxen uncheck after ajax refresh
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/
October 30, 2018 at 6:33 pm #192218In reply to: Search results
TrevorParticipantAh, I can see what you have done now. It would need for part of the blog page template to be placed in the results.php file and for the blog template instead of calling the results shortcode, to call the content.
I can write this for you if you want:
In blog-page.php change lines 24-29:
<div class="page-blog page-blog-title">Recent posts</div> <div class="blog-posts"> <?php echo do_shortcode('[searchandfilter id="463" show="results"]');?> </div> </div>
with:
<?php the_content(); ?>
Next, in the results.php file, find lines 68 and 69:
</a></a> </div>
I believe these have errors and should be just:
</a>
At the very end of the file is a blank line, after this:
else ?> <?php { } ?>
Here add two closing tags:
</div> </div>
Now find lines 25 and 26 (which are blank) and paste these lines:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(463)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { $page_title = "Recent Posts"; } else { $page_title = "Search results for: " . $sf_current_query->get_search_term(); }?> <div class="page-blog page-blog-title">Recent posts</div> <div class="blog-posts">
I think that will do as you want. The title must be inside the results.php for it to be affected by if there are results.
October 30, 2018 at 1:50 pm #192127In reply to: Search results
TrevorParticipantThe text that says Recent post is what that line I highlighted makes. In any event that lines needs to be this instead, I think (try it):
<div class="blog-post__title"><?php the_title();?></div>
So, you would now need to find out if the page is filtered, like this, where the last line replaces line 42:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { $page_title = the_title(); } else { $page_title = "Search results for: " . $sf_current_query->get_search_term(); }?> <div class="blog-post__title"><?php echo $page_title;?></div>
Note that this only shows the text search term. If you want fields choices, taxonomy choices, it becomes more complicated, which is what that documentation page shows how to do..
October 29, 2018 at 10:54 am #191996
TrevorParticipantAs you are using the WooCommerce method to display results, it is your theme and/or WooCommerce that controls the output of the HTML and results. If you have access to the PHP template file being used, this PHP will generally detect if a search has been made or not:
global $searchandfilter; $sf_current_query = $searchandfilter->get(20549)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { // your template archive code to show when there is search yet } else { // your template archive code to show search results }
October 19, 2018 at 12:19 pm #191321In reply to: Stop loading results on page load
TrevorParticipantAs you are using the Shortcode results method, and our results.php template file (infinite scroll version), it would look 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 template archive code/loop OR results.php code here }
Change 1024 to the ID number of your form (from the form shortcode).
October 16, 2018 at 12:31 pm #191069In reply to: Echo the query/search term
TrevorParticipantDo you have this bit:
echo $sf_current_query->get_search_term();
October 16, 2018 at 12:23 pm #191067In reply to: Echo the query/search term
AnonymousInactiveI don’t have any other filters, and the first link/example doesn’t seem to work.
<?php
//grab the active query from our search form
//replace1526
with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1445)->current_query();
?>This should grab the search term and output it on the page, right?
October 16, 2018 at 11:58 am #191063In reply to: Echo the query/search term
TrevorParticipantShowing 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/
October 10, 2018 at 4:00 pm #190680In reply to: Current filters and reset buttons
TrevorParticipantShowing them is one thing, and quite complex, but I can give you links. Adding x’s to remove them is far more difficult. You would, in either case, have to do the coding yourself, as such custom coding is outside of our normal support. I think this feature is coming in V3, which is in development.
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/
October 9, 2018 at 7:35 am #190495In reply to: Limit search results before filtering
AnonymousInactivePerfect, that works. Thank you very much!
For others, the answer was to add the following lines in the results.php, which adds a “not-sf-filtered” or “sf-filtered” class:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1075)->current_query(); if (!$sf_current_query->is_filtered()) { $is_filtered = " not-sf-filtered"; } else { $is_filtered = " sf-filtered"; } ?> <div class="content-width<?php echo $is_filtered;?>">
-
AuthorSearch Results