Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Limit results pages
This topic contains 2 replies, has 2 voices, and was last updated by rafaschutz 6 years, 11 months ago.
- AuthorPosts
- December 21, 2016 at 4:11 pm #11340
Hi,
I’m having some problems limiting the results of results page. i’ve already searched the knowledge base and forums, and already tested some codes, without sucess.
I using the search restults in 3 diferrente pages, each one with a different limit off results per page:
https://www.agemed.com.br/?s=clinica%20joinville#search (with 50 results per page)
https://www.agemed.com.br/?s=clinica%20joinville&t=map (with all results on page – over than 1000)
https://www.agemed.com.br/?s=clinica%20joinville&t=print (with all results on page – over than 1000)I’ve set the wp posts_per_page on admin, which is affecting all pages;
I’ve tried to change the posts_per_page parameters, on wp and asp hooks and filters based on the page, but nothing changes. What hook should i use?
Can you help?
December 22, 2016 at 12:59 pm #11346Hi,
The plugin uses the global “posts_per_page” by default. If the search override is active, then the best solution in my opinion is to use the asp_query_args filter, like so:
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 22, 2016 at 1:36 pm #11348Hi, thank for the reply.
But i’ve already tried this, and changing the results posts_per_page didnt affected the query.
I’ve solved the problem by overriding the GLOBAL posts_per_page for each page on the filter pre_option_posts_per_page:
/////////////////////////////////////////////
add_filter(‘pre_option_posts_per_page’, ‘override_limits’);function override_limits() {
if(isset($_GET[“t”])) {
$searchtype = $_GET[“t”];
}
else {
$_GET[“t”];
}if($searchtype==”map”||$searchtype==”print”) {
$limit = -1;
}
else {
$limit = 50;
}return $limit;
} - AuthorPosts
You must be logged in to reply to this topic.