This is the standard results.php template file:
<?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 this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
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><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>
</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";
}
?>
The strings you want to translate are like this:
Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
In the file I showed above, these are on lines 34/35.
Then on line 78 is this:
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
Are those the lines you need?
AnonymousInactive
Hello Trevor,
In suit of my ticket #270629 not display, i create new ticket.
You give me 1 solution to translate some terms, but not all.
Your indication :
“If you are using the Shortcode display results method, you need to follow the customising guide here:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
And use the numbering the filename option instead of a generic results.php file (e.g. name one language the file 1452.php), and then you can translate those strings directly in the specific language versions. Each language will have its own form with its own ID number that you use.”
translate only the term “Previous, Next and No results founds”.
I want to translate “Page ?? of ??” and “Found ?? results”.
Is all this terms (previous page, next page, no results found, page ?? of ??, found ?? results)have class to remplace in css ?
Thanks
Patrick
I am not sure that I understand? Only the Shortcode display results method uses the results.php template file (and you can alternatively make a template file specific to one form by naming it after the ID of the for, e.g. 1234.php.
AnonymousInactive
Hi, thanks for answering my question but I did not quite get the code steps.
1. I created the folder.
2. I have a copy of the results.php file
3. How can I now make the following post to be shown as the starting page in my display of results-area?
https://urban-digital.de/10374-2/
Yes, that is possible. I see that you are using our Shortcode method …
… in which case you should follow the ‘guide to customising’:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/
Once you have a copy of the results.php
file in a search-filter sub-folder of your theme, you can edit that file, like this (leave the PHP comments at the top outside and before this code):
global $searchandfilter;
$sf_current_query = $searchandfilter->get(10265)->current_query();
if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()==””)) {
// code to display the blog post here
} else {
// the current resuts.php code here
}
I will address these in reverse. We do not yet have a way to offer such search boxes based on a certain data source. I do not know if this is coming in V3.
As to the first question, it might be possible to edit the results.php template file for our shortcode method to use the same code as a page like this:
https://www.operaonvideo.com/?s=advents
I changed the search form to use that same theme template page, and this is what the results look like:
https://www.operaonvideo.com/?sfid=90860&_sf_s=advents
A general note first:
Our plugin files are located on your server in this location:
…/wp-content/plugins/search-filter-pro
There you will find a sub-folder named templates
and in that a file named results.php
.
This documentation:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
tells the user to copy that file to their child theme folder, and place it in to a sub-folder that they should name search-filter
Note that it is always good practice to use a child theme (this is a WordPress recommendation), as it stops updates of a theme from overwriting or deleting any changes and customizations).
Similarly, if you fail to make that copy of the result.php template file and make your edits to that, then, when our plugin updates, it will overwrite the results.php file in our plugin templates folder.
So, having done that, you can then edit that copied file, and remove what you do not need. Probably these lines:
<p><?php the_category(); ?></p>
<p><?php the_tags(); ?></p>
<p><small><?php the_date(); ?></small></p>
AnonymousInactive
Having trouble overriding the results.php file via my child theme. Path in theme is as follows: astro-child/search-filter-pro/templates/results.php
Any help is appreciated! Thanks!
You would need to edit the results.php template file and change the coding for the link to include target="_blank"
to the link HTML tag. Like this:
<h2><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></h2>
Hi Tricia
Actually, for things like that, I like to create shorcodes, it can be quite simple:
https://wordpress.stackexchange.com/a/213706/37783
So using that, and combining it with a WP_Query:
https://searchandfilter.com/documentation/search-results/custom/#wp-query
You would get something like:
function get_search_search_results($atts) {
ob_start();
$args = array(
'post_type' => 'post',
'search_filter_id' => 123,
);
$query = new WP_Query($args);
// now you can loop through the results just like in results.php -
// and maybe load a template, or any other PHP file - eg - get_template_part( 'my-loop' );
// in between 'ob_start' and 'ob_get_clean' you can do stuff like "echo" as normal
return ob_get_clean();
}
add_shortcode( 'my-search-results', 'get_search_search_results');
And you can use that loop / template anywhere via – [my-search-results]
Let me know how you get on and if all is clear above!
Best