This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Empty search on child site

#19307
Ernest MarcinkoErnest Marcinko
Keymaster

Hi!

Thank you for all the details, it helped me a lot!

I have found a possible issue, and resolved it. Now I am seeing the same results on the results page, as on the live results list. One of the main post filters was not executed for some reason. Either it is de-registered somewhere, or it is missing, I am not sure. Anyways, I have added this line to the search.php child theme file, to the top:

[php]$wp_query->posts = apply_filters(‘posts_results’, $wp_query->posts, $wp_query);[/php]

That will make sure to allow search results override. I have also added these lines to the functions.php file as well, to resolve the blog switching for multisite results:

[php]function asp_fix_the_post_action( $post_object ) {
if (
isset($post_object->blogid, $post_object->asp_id) &&
!empty($post_object->asp_id) &&
get_current_blog_id() != $post_object->blogid &&
isset($_GET[‘s’])
) {
switch_to_blog($post_object->blogid);
$np = get_post($post_object->asp_id);
$post_object->ID = $np->ID;
$post_object->post_type = $np->post_type;
}
}
add_filter( ‘the_post’, ‘asp_fix_the_post_action’ );[/php]

These should do the trick.