Created
October 17, 2012 05:09
-
-
Save ericpedia/3903803 to your computer and use it in GitHub Desktop.
Relevanssi returns zero results in custom query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$wp_query = new WP_Query( array( | |
'post_type' => 'any', | |
'posts_per_page' => '5', | |
// If we just set the vars above, the query returns posts as expected. But setting | |
// a search term causes the query to return 0 results (if Relevanssi is activated) | |
's' => 'test', // or get_search_query(), or a variable containing search term | |
) ); | |
// Testing confirms that posts_per_page and s are being set | |
echo $wp_query->query_vars['posts_per_page']; // works | |
echo $wp_query->query_vars['s']; // works | |
if (is_search()) echo 'This is a search.'; // works | |
// Wrapping query in relevanssi_do_query() kills results | |
// relevanssi_do_query($wp_query); | |
// Displays the posts | |
get_template_part( 'loop', 'blog' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment