Skip to content

Instantly share code, notes, and snippets.

@ericpedia
Created October 17, 2012 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericpedia/3903803 to your computer and use it in GitHub Desktop.
Save ericpedia/3903803 to your computer and use it in GitHub Desktop.
Relevanssi returns zero results in custom query
<?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