Forums › Forums › Search & Filter Pro › Search results questions
Tagged: V3
- This topic has 14 replies, 2 voices, and was last updated 4 years, 4 months ago by Trevor.
-
Anonymous(Private) May 25, 2020 at 12:58 am #245665
Thank you for the great plugin, I have a few customization requests to my search results page and I was wondering if I could get the help because I have very litle experience with coding. My page is https://hcegstage.wpengine.com/resources/
1- Is it possible to move the search results count over to the right and make it all on one line ” Found ____ Results, Page 1 of ___, Older Posts”.
2- Is it possible to only show the results count AFTER a search has been made?
3- Can you reduce the space between the title and the featured photo on the displayed results?
4- is there a way to get the data on the most searched terms from our site visitors?Trevor(Private) May 26, 2020 at 11:24 am #245870You have chosen to use for now our Shortcode display results method, which means that the style of the display is somewhat basic, but can be customized by yourself:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
It depends what content you want (what taxonomies, images, description, custom fields) and layout you want, as that will determine how easy it will be to do.
#1 This code:
Found <?php echo $query->found_posts; ?> Results<br /> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
Would become this:
<div style="text-align: right">Found <?php echo $query->found_posts; ?> Results, Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></div>
#2 The above code would then become:
<div style="text-align: right"> <?php global $searchandfilter; $sf_current_query = $searchandfilter->get(13622)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { } else { ?> Found <?php echo $query->found_posts; ?> Results, <?php } ?> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></div>
#3 This space?
https://www.screencast.com/t/GuYOFQ3qtQ3l
There appears to be blank lines in your content:
https://www.screencast.com/t/SivDBdT69fK
#4 This would require our filter to use (or be able to use) transients, which it cannot at present. I believe this will be added when we release V3, towards the end of June/early July.
Even then, you would probably require the services of a coder to hook it all up.
Anonymous(Private) May 26, 2020 at 1:19 pm #245893Thank you trevor for your response. For #1 and #2, where do I put this code? am I replacing a code that already exists? I am new to coding and do not want to break it.
#3- i do not see blank lines on the original content that the feed is displaying.
https://hcegstage.wpengine.com/wp-content/uploads/Screen-Shot-2020-05-26-at-8.15.08-AM.png
original post: https://hcegstage.wpengine.com/surviving-coronavirus-pandemic-thriving-on-the-other-side-rapid-innovation-telehealth/the same space is displaying in the search results for all of the posts/ resources it is displaying, and there are not blank lines at the beginning of the content to which i can see. could it be something with the display settings? is it trying to show an excerpt or something that is not there?
Anonymous(Private) May 31, 2020 at 7:35 pm #246684Also, is it possible in the settings somewhere to open up individual search results in a new tab? I want the filtered returned results to show up next to the filter, but if I select an individual post for example that comes up as part of the search results, can it open that post in a new tab? So that the original search results are still there on a different tab?
Trevor(Private) June 8, 2020 at 4:43 pm #247896You could try simply copying across the child theme folder, yes, which would include the search-filter sub folder. Then activate that child theme.
Where are the tags not sorted? In the post results? I think this:
<?php function compare_tags_naturally($a, $b) { return strnatcmp($a->name, $b->name); } $unsorted_tags = get_the_tags(); $tags = usort($unsorted_tags, 'compare_tags_naturally'); ?> <p><?php echo implode(', ', $tags); ?></p>
could replace:
<p><?php the_tags(); ?></p>
mmm, but, I think that function may need to be towards the start of the file
So, before this line:
if ( $query->have_posts() )
… put this:
function compare_tags_naturally($a, $b) { return strnatcmp($a->name, $b->name); }
Then, replace this:
<p><?php the_tags(); ?></p>
… with this:
<?php $unsorted_tags = get_the_tags(); $tags = usort($unsorted_tags, 'compare_tags_naturally'); ?> <p><?php echo implode(', ', $tags); ?></p>
Not sure if it would work.
Anonymous(Private) June 29, 2020 at 5:52 pm #250548Hi Trevor thank you for the help- I tried adding the code to the top and replacing and it did not sort the tags alpahbetically. Where I am trying to accomplish this is the left side “Tags” filter on the resources page (https://hceg.org/resources/) before and after filtering.
Here is the current code I updated on the search-filter/results.php 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
*
*/function compare_tags_naturally($a, $b) {
return strnatcmp($a->name, $b->name);
}
if ( $query->have_posts() )
{
?><div style=”text-align: right”>
<?php global $searchandfilter;
$sf_current_query = $searchandfilter->get(13622)->current_query();
if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()==””)) { } else { ?>
Found <?php echo $query->found_posts; ?> Results,
<?php } ?>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?></div><div class=”pagination”>
<div class=”nav-previous”><?php next_posts_link( ‘Previous’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Next’ ); ?></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>” target=”_blank” class=”read_more_link”><?php the_title(); ?></h2><?php the_excerpt(); ?>
<?php
if ( has_post_thumbnail() ) {
echo ‘<p>’;
the_post_thumbnail(“small”);
echo ‘</p>’;
}
?>
<p><?php the_category(); ?></p>
<?php
$unsorted_tags = get_the_tags();
$tags = usort($unsorted_tags, ‘compare_tags_naturally’);
?>
<p><?php echo implode(‘, ‘, $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( ‘Previous’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Next’ ); ?></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”;
}
?> -
AuthorPosts