Forums › Forums › Search & Filter Pro › Pagination
- This topic has 19 replies, 2 voices, and was last updated 4 years, 1 month ago by Trevor.
-
Trevor(Private) November 6, 2020 at 10:58 am #265417
Normally, the best way to stop pagination appearing and show only a limited number of posts is to hide the pagination using CSS, or to edit the the PHP template for the page, if it uses a normal PHP template.
Are you able to send me a live link/URL to your search page so I can take a look?
As to the text search being empty, that depends again on the PHP template for the page.
Trevor(Private) November 10, 2020 at 9:42 am #265739I see that you are using our Shortcode method …
… in which case you should follow the ‘guide to customising’:
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(11690)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // the current resuts.php code here }
This code will prevent any results from showing UNTIL a search has been made. If you need to modify it a little, at least it should give you some ideas.
You can show ALL results (no pagination) if you set in the form on the General settings tab the ‘Results per page’ to
-1
.The you need to remove the pagination output from the results.php code, so delete the two blocks that look like this (one before the loop, one after):
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>
Anonymous(Private) November 10, 2020 at 2:28 pm #265810Thanks for the help, I tried, the results.php page is composed as follows:
global $searchandfilter;
$sf_current_query = $searchandfilter->get(11690)->current_query();
if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()==””)) {
echo ‘<div>Nothing to see here folks!</div>’;
} else {
// the current resuts.php code here
}?>
<?php
while ($query->have_posts())
{
$query->the_post();?>
<div class=”farmacia”>
<h2 class=”nome-farmacia”>“><?php the_title(); ?></h2>
<?php the_content(); ?></div>
<hr />
<?php
}
?>If I go to https://www.staging2.biotechmed.it/farmacie/ it shows me all the results… My client does not want that someone can easily see all the results and download all the names.
Another question, is it possible to search only in two specific fields and ignore the others in the search?
Trevor(Private) November 10, 2020 at 3:12 pm #265815I would need to see the code for results.php, but that does not look right. Can you show me the results.php file contents? You can share the file using a file sharing site, or post/paste the code in your reply here. Please post any code inside code ticks (one before the code, one after)? On my UK Windows keyboard, the code tick key is next to the 1 key in the standard part of the keyboard. If you do this Google search and look at the images, they show various keyboards and where the key is located:
https://www.google.com/search?q=back+tick+code+key
As to the search. I think you may be able to restrict the text search to just two fields. Our plugin does not directly allow you to do text searches of individual Post Meta (custom fields) and Taxonomy (Category, Tags and Taxonomies) data/terms. The Search & Filter Pro Text Search field uses the standard WordPress search, so looks only in the Post Title and Content. To help you control this better, on the form’s Advanced settings tab you will see 2 settings for Relevanssi.
The documentation for this is here:
https://www.designsandcode.com/documentation/search-filter-pro/3rd-party/relevanssi/
You would need to install and activate the free Relevanssi plugin as well.
Then set Relevanssi up and build its index (make sure it is indexing the desired post types, custom fields AND any taxonomy that you want to search).
What I am not sure is if you can exclude the title, content, etc in the Relevanssi settings. You may need to use hooks in Relevanssi to force it to NOT look at title for example, see this post:
https://support.searchandfilter.com/forums/topic/search-and-filter-only-in-title/#post-93961
Anonymous(Private) November 10, 2020 at 4:24 pm #265838global $searchandfilter; $sf_current_query = $searchandfilter->get(11690)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // the current resuts.php code here } ?> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class="farmacia"> <h2 class="nome-farmacia"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> </div> <hr /> <?php } ?>
So you see it correctly?
Trevor(Private) November 10, 2020 at 4:26 pm #265842I think it should look like this:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(11690)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { while ($query->have_posts()) { $query->the_post(); ?> <div class="farmacia"> <h2 class="nome-farmacia"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> </div> <hr /> <?php } }
-
AuthorPosts