By the way, I’m not saying the line should be added at this very place. It was the easiest place to put it for me to explain the issue. 🙂
I think this is definitely a bug, but I think the problem spot is actually where it’s passing the maxResults parameter when applying the filter:
$wpQueryResults = apply_filters( 'dwls_alter_results', $wpQueryResults, -1, $this );
There’s a hardcoded -1 being sent to as the max results for the filter but I think this should really be the max results option, which is modified before being applied as the post_per_page in the pre_get_posts action. Anyway, I think that line should be something like:
$maxResults = $wp_query->get( 'posts_per_page' );
$wpQueryResults = apply_filters( 'dwls_alter_results', $wpQueryResults, $maxResults, $this );
Hi!
I’m trying to get Relevanssi to work with DWLS, bit I’m not able to get this working.
Where do I add this code? functions.php??
Thanks 🙂
@Hkroed sorry no, the code above would have to be a change made to the actual plugin code.
Alternatively you may be able to implement your own filter using code similar to the code in the second screenshot.
Thank you (@blakers) for your code suggestions/fix 🙂
I had been having inconsistent live results too using ‘Dave’s WordPress Live Search’ plugin with ‘Relevanssi Search’ plugin.
Results would start to show and the more letters I added, then the correct result would disappear. If I deleted some letters, the correct result would start showing again.
Very weird and was pain.
For people who are not sure what file to edit, download the file called ‘class-daves-wordpress-live-search-results.php’ from ‘/wp-content/plugins/daves-wordpress-live-search’ folder. Save a copy of the original just incase you want to revert back to it.
Find this (was line 49 for me):
$wpQueryResults = apply_filters( 'dwls_alter_results', $wpQueryResults, -1, $this );
And replace line 49 with this:
// $wpQueryResults = apply_filters( 'dwls_alter_results', $wpQueryResults, -1, $this );
// Above commented out and replaced with the 2 lines below
// sourced from blakers: https://wordpress.org/support/topic/relevanssi-missing-results/
$maxResults = $wp_query->get( 'posts_per_page' );
$wpQueryResults = apply_filters( 'dwls_alter_results', $wpQueryResults, $maxResults, $this );