Support » Plugin: Relevanssi - A Better Search » Relevanssi used with ajax, little pagination issue

  • Resolved shortster


    I’m using Relevanssi to display search results with ajax. This works fine, however, pagination will not work because is_paged() returns nothing (relevanssi/lib/search.php line 737)

    To make the plugin a little more flexible could you please replace the is_paged() call with a check if the query_vars[‘paged’] is bigger than 0. It’s the same thing except now it’s possible to use this variable to show the right page in the pagination using:

    $query->query_vars['s'] = 'search term';
    $query->query_vars['posts_per_page'] = 10;
    $query->query_vars['paged'] = $_POST['paged'];

    The change in relevanssi/lib/search.php lin 737:

    if (is_paged()) {


    if ($query->query_vars['paged'] > 1) {

    Unless you know a better way of course, I really don’t want to alter the plugin’s code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • shortster


    Fixed it using a different route. Maybe helpful for someone else, here’s what I did.

    Inside my function:

    global $wp_query;
    $wp_query = new WP_Query('paged=' . $_POST['paged']);
    $wp_query->query_vars['s'] = $_POST['search'];
    $wp_query->query_vars['posts_per_page'] = $postPerPage;
    if($wp_query->have_posts()) {
          while ($wp_query->have_posts()) : $wp_query->the_post();
                 <a href="<?php the_permalink(); ?>" rel="external"><?php the_title();?></a>
    Plugin Author Mikko Saari


    Glad to hear you were able to fix it. I did make the change, though, it’ll be effective from the next version on.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Relevanssi used with ajax, little pagination issue’ is closed to new replies.