Limit results pages

This topic contains 2 replies, has 2 voices, and was last updated by rafaschutz rafaschutz 7 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #11340
    rafaschutz
    rafaschutz
    Participant

    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?

    #11346
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #11348
    rafaschutz
    rafaschutz
    Participant

    Hi, 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;
    }

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.