AnonymousInactive
I found documentation that says to copy the contents of wp-content\plugins\search-filter\templates\results.php and paste to wp-content\themes\search-filter/results.php and make customizations there. However, I do not see a file named results.php, nor is there a folder named templates. Please help.
Do NOT delete that old version from WordPress, as it will delete the forms (the latest version does not do that).
Did you edit any of the files (like the results.php template file)? If so, you need a copy of that.
Use ftp to delete the folder, then go to plugins and add the new version and activate it.
In the results.php template file, what happens if you comment out or remove lines 162 to 165:
function shorten_image_title( $title, $settings ){
return substr( $title, 0, (int)$settings['archive_title_length'] );
}
OR, change the function name (also twice in the code above), to sf_shorten_image_title?
If this function is used also by your theme, that may be the conflict.
Hi
If you followed that guide, you will have a copy of our results.php file in your child theme folder (in a sub-folder named search-filter).
Yes you can edit the file. It follows the WP Codex standard for making an archive page. Most likely your theme archive.php file will look similar, and it is the section inside the while loop that you shoudl focus on. It is quite likely that your theme code can be transplanted here, but it may require some modification to get it to work, depending on how closely your theme also follows the same WordPress Codex standards.
We don’t have a guide as to how to do this, as every case would be very different.
AnonymousInactive
Hi I am having trouble getting any data other than the example fields to display in my search results
I would like to display product price, product attributes etc. on my custom results.php page.
I have previously done this using ACF eg. the_field(fieldname), but i çant find the syntax/ field names to reference for woocommerce.
All my HTML is working, im just note sure what i should be referencing to return product specific data in the results.
Full disclaimer – not a PHP person
‘thank you
AnonymousInactive
Hello!
I am experiencing a strange problem.
We are using S&F Pro for displaying a CPT. The CPT is using custom roles that I’ve added using Pods and it is making use of a custom capability.
The active page is displayed using a Beaver Themer layout, as we need different Search and filter objects depending on the current user role.
When logging in as our custom admin, the admin bar is not showing and we also get a fatal error cannot redeclare function. This ONLY happens with the custom role, not on the administrator or our other custom roles. I am not sure what to do, but as the admin bar works when S & F Pro is deactivated I am reaching out to you first.
Regards,
AnonymousInactive
For all users got the same idea:
If you are in your results.php file, just add a counter and a variable for the current permalink right under the query inside the loop:
...
$query->the_post();
$resultcount++;
$resulturl = get_permalink();
...
then you can redirect to the page of the one and only result outside the loop:
<?php if ($resultcount == 1) {
echo "<script>parent.self.location='".$resulturl."';</script>";
} ?>
AnonymousInactive
Hey Trevor,
If possible, I’d like the curated content pages to use the same results.php template because I’d like the styling of the results to be consistent across the site. However they should be their own page, with their own unique URL for SEO reasons. On these pages, I would not surface the search bar at all, so the user wouldn’t be able to change the results in any way.
AnonymousInactive
Currently I’m using a single search form with a custom results.php template and displaying that via shortcode. I want to duplicate the exact same thing except I’d like to show pre-filtered results, e.g. results that have a certain dropdown value already selected when the page loads. This would allow me to create “curated content” pages with results from a specific category, for instance, and a custom URL. How can I do this? I can’t find anywhere in the search fields options to set a default value.
Thanks in advance!
This is our standard infinite scroll results.php template modified to have a no results message. Use this as a starting point:
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link http://www.designsandcode.com/
* @copyright 2015 Designs & Code
*
* 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 />
<div class='search-filter-results-list'>
<?php
while ($query->have_posts())
{
$query->the_post();
?>
<div class='search-filter-result-item'>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></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>
<hr />
</div>
<?php
}
?>
</div>
<?php
} else {
//figure out which type of "no results" message to show
$message = "noresults";
if(isset($query->query['paged'])) {
if($query->query['paged']>1){
$message = "endofresults";
}
}
if($message=="noresults") {
?>
<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
<span>No Results Found</span>
</div>
<?php
} else {
?>
<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
<span>End of Results</span>
</div>
<?php
}
}
?>