Support » Plugin: Relevanssi - A Better Search » `max_num_pages` wrong when `-1 === posts_per_page`

  • Resolved josaffe


    Hello Mikko,

    If I set $query->set( 'posts_per_page', -1 ); in 'pre_get_posts', max_num_pages will be the number of results. It should be equal to 1.
    Since Genesis’ pagination uses this value, it will display pagination when there should be none.

    I think the mistake is in relevanssi/lib/search.php:906:

    if ( -1 === $query->query_vars['posts_per_page'] ) {
        $query->max_num_pages = $hits_count;

    $hits_count should be replaced with 1 (or the case could be dropped completely).

    Is there a reason that I didn’t see, why it is set this way?

    Thank you,

    PS: In the meantime it is avoided by using $query->set( 'nopaging', true );, since posts_per_page is not set this way.

    • This topic was modified 1 year, 2 months ago by josaffe.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘`max_num_pages` wrong when `-1 === posts_per_page`’ is closed to new replies.