• Hey Mikko,

    Since the earliest versions of Relevanssi, I’ve used a custom query to manually “set” the number of search results returned, i.e.

    $queryString = "post_type=post" .
    	       "&s=" . get_query_var('s') .
    	       "&posts_per_page=" . $postsPerPage .
    	       "&paged=" . get_query_var('paged');
    $my_query = new WP_Query($queryString);

    This always worked, until 2.7.4. Suddenly, regardless of the value of $postsPerPage, it always returns a number equal to the posts-per-page count set in the WP options. Any idea what would’ve caused this, and how I can get back to “manually” setting a result count?

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Mikko Saari

    (@msaari)

    There are no changes in 2.7.4 that should affect this, as far as I know, just some bug fixes in the matching logic, mostly.

    Thread Starter kuprosa

    (@metal450)

    That’s kindof what I thought having glanced through a diff of the code, but I’m 100% sure that from 2.7.3 to 2.7.4, the behavior described above is accurate. No other variables changed: I went back and forth between the two versions twice to confirm…

    Plugin Author Mikko Saari

    (@msaari)

    That’s odd. I’ll have to investigate. Adding a control for posts_per_page has been in the works.

    Plugin Author Mikko Saari

    (@msaari)

    I got it to work like this:

    $queryString = "post_type=post" .
    	       "&s=" . get_query_var('s') .
    	       "&posts_per_page=3" .
    	       "&paged=" . get_query_var('paged');
    $my_query = new WP_Query($queryString);
    relevanssi_do_query($my_query);

    Replace have_posts() with $my_query->have_posts() and so on. I’m running Relevanssi Premium 1.1.2, though, but in this regards, it should be functionally identical to Relevanssi 2.7.4.

    Thread Starter kuprosa

    (@metal450)

    Hmm…well, previously I’d never called relevanssi_do_query() – simply doing $my_query = new WP_Query($queryString) and then iterating through $my_query->have_posts() was sufficient to get the results. Is this not going to result in duplicate work?

    One possible thing to check: what happens if you set posts_per_page to a number *higher* than the value set in the WP options? I’ve got WordPress set at 5 (i.e. for my main front page, http://www.justin-klein.com), but posts_per_page overridden to 35 for searches (i.e. http://www.justin-klein.com/?s=test&searchsubmit=)

    Separate note: congrats on the premium addon release. That’s *exactly* what I ended up doing with my most popular plugin, http://www.justin-klein.com/projects/wp-fb-autoconnect 🙂

    Plugin Author Mikko Saari

    (@msaari)

    Hmm, if I set it higher than the WP option (which is 10), I get 10 results and errors after that. So, a problem.

    I’ll have to investigate.

    Thread Starter kuprosa

    (@metal450)

    Well, glad you were able to reproduce it at least. Step 1! 🙂

    Plugin Author Mikko Saari

    (@msaari)

    Actually, I can’t get your code to work in 2.7.3 either.

    Thread Starter kuprosa

    (@metal450)

    What does it do? You can see here:

    http://www.justin-klein.com/?s=test&searchsubmit=

    That it does indeed work (showing 35 posts per page, when the “global” setting is only 5, as you can see on the main page http://www.justin-klein.com/)

    Plugin Author Mikko Saari

    (@msaari)

    The code has no effect whatsoever. Might be a theme thing, though.

    How does your search results template continue after that?

    Thread Starter kuprosa

    (@metal450)

    Replied in detail via email

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Relevanssi – A Better Search] Behavioral Change 2.7.3 -> 2.7.4’ is closed to new replies.