Confusion with $wp_query->found_posts
-
I’ve got a problem with the
found_postsaspect of Relevanssi. I’m creating my ownWP_Queryobject and calling it like so:$q = new WP_Query($query_args); $posts = $q->get_posts(); $count = $q->found_posts;So this is not the
global $wp_query, it’s a separate instance. This code isn’t working when Relevanssi is switched on –found_postsis always zero. I think it comes down to therelevanssi_querymethod inrelevanssi/lib/search.php:function relevanssi_query($posts, $query = false) { ... global $wp_query; ... $posts = relevanssi_do_query($wp_query); ... }It seems to be completely ignoring the
$queryargument, and always uses the global. Even if the arguments in the global query are the same, this means it doesn’t store thefound_postsvalue where it’s needed.Am I misunderstanding, or is this a bug?
The topic ‘Confusion with $wp_query->found_posts’ is closed to new replies.