Using “Search” for searching all questions displaying all results?
When a website visitor is using “Search” for searching all questions, rather than displaying the results from their specific search the content below is just the list of all results.
Also, I see that Ans 4.1.5 is out, but WP repository doesn’t show that it isn’t available?
Hi Rahul,
for themes like the one that florinb has, who have an option to include just “posts” in search, i think you need to add the post_type to your “loop_start” hook from qaquery_hooks.php .
so instead of
if ( $query->is_main_query() && $query->is_single() && ‘question’ === get_query_var( ‘post_type’ ) ) {
$query->posts[0]->post_content = ‘[anspress]’;
}
you should have
if ( $query->is_main_query() && $query->is_single() && ‘question’ === get_query_var( ‘post_type’ ) ) {
$query->posts[0]->post_content = ‘[anspress]’;
$query->posts[0]->post_type = ‘post’;
}
this way, you’ll make sure your injected post is treated as a “post”.
Hello,
Thanks for your suggestion. I will give it a try.