Using “Search” for searching all questions displaying all results?

9.26K viewsCoresearch
0

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?

Answered question
1

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”.

Posted new comment

Hello,
Thanks for your suggestion. I will give it a try.

You are viewing 1 out of 7 answers, click here to view all answers.