If 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).
AnonymousInactive
Hello,
I am trying to edit results.php that i moved to created folder in my theme folder. i did some testing with echo and that part is done correctly. So, I’m using CPT and i have custom fields in my custom post type “nekretnina” that i’m applying search for and I’m getting the results, but i want to show custom fields from those results that im searching for in my results.
Example.
CPT nekretnina is searched by price,
CPT has the custom meta field brojsobe.
How do i call this custom field in the while loop in results.php so that i can show it in my page.
Very Respectfully, Dan.
To show them in columns (effectively a grid, would mean you would need to code the template to have HTML and CSS to make this happen.
As you are using our shortcode method the display of the results comes from our results.php file. You would need to customise it as described (in basic form) here:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
You need to remove the lines::
<p><?php the_category(); ?></p>
<p><?php the_tags(); ?></p>
<p><small><?php the_date(); ?></small></p>
To remove the featured image, remove these lines:
<?php
if ( has_post_thumbnail() ) {
echo '<p>';
the_post_thumbnail("small");
echo '</p>';
}
?>
The HTML shown there (the part that starts div id=lightgallery-1") is not from our normal results.php file. Are you able to show me the PHP/HTML that makes that part?
AnonymousInactive
I’ve set it up like this. Works fine. Only with the problem that it shows all posts at first load. I need it empty
[searchandfilter id=”36613″ action=”filter_next_query”]
[post_grid id=”40757″]
If I understand correctly I have to put your code in a results.php
I can’t find such php in the “post-grid” – plug-ins phps
Also not in the Standart WordPress directory…
AnonymousInactive
Thanks for the advice. That’s nice didn’t know renaming result to the form ID will work and make it possible to have multiple result.php versions.
The map is crashing the server (haha) so you were right. Now we try another code structure on the map results.php so we don’t have to generate so much at once and try to do some lazy loading. Hope we will get it to work.
AnonymousInactive
Just an update for issue 3, I muddled my way through copying that results.php template. I’ve managed to make most of the changes I wanted to achieve. The results now only show the image (yay!) but you can’t click them haha.
Are you able to tell me how I would make the thumbnails clickable through to their respective posts? I tried and I broke it…
Also, would you know how to make it into 3 columns (that reduce to two, then one, when the window gets smaller) instead of one giant image after another vertically?
My PHP code is below.
<?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() )
{
?>
<?php
while ($query->have_posts())
{
$query->the_post();
?>
<div>
<?php
if ( has_post_thumbnail() ) {
echo '<p>';
the_post_thumbnail("small");
echo '</p>';
}
?>
</div>
<?php
}
?>
<?php
}
else
{
echo "No Results Found";
}
?>
Yes, 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
}
Possibly. Our shortcode method uses a default template called results.php, as detailed in this page:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/
You are able to customize this (see the above documentation) and compare our template to the archive.php template you are using. The basic structure of our results.php file looks like this (pretty much standard structure for a WordPress archive template file):
<?php
if ( $query->have_posts() ) {
// do anything here that will appear before the actual posts, like pagination,number of results, etc.
while ($query->have_posts()) {
$query->the_post();
// output each post with whatever HTML and content you need
}
// do anything here that will appear before the actual posts, like pagination,number of results, etc.
} else {
echo "No Results Found";
}
?>
You would need to match up what is inside your template and copy and past, and it should work.
AnonymousInactive
Hi! Still loving this plugin. It quickly became a favorite. Quick question: I have results.php with the following else:
`
else
{
?>
<div class=’search-filter-results-list’ data-search-filter-action=’infinite-scroll-end’>
<h3>We couldn’t find anyone with “<?php
global $searchandfilter;
$sf_current_query = $searchandfilter->get(4716)->current_query();
echo $sf_current_query->get_search_term();
?>”.</h3>
</div>
<?php
}
`
My problem though is that when I sort by a taxonomy, eg orgs or divisions with a drop down cromobox without a search term the "". is left blank. What do I need to add to the above to return the taxonomy/taxonomies?
Thanks!