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

  • Resolved josaffe

    (@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,
    Josef

    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 5 months, 2 weeks ago by josaffe.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.