WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
Behavioral Change 2.7.3 -> 2.7.4 (12 posts)

  1. metal450
    Member
    Posted 3 years ago #

    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!

  2. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  3. metal450
    Member
    Posted 3 years ago #

    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...

  4. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

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

  5. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  6. metal450
    Member
    Posted 3 years ago #

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

  7. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  8. metal450
    Member
    Posted 3 years ago #

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

  9. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

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

  10. metal450
    Member
    Posted 3 years ago #

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

  11. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

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

    How does your search results template continue after that?

  12. metal450
    Member
    Posted 3 years ago #

    Replied in detail via email

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags