-
-
Save searchwpgists/505845bd806359af08688b132c6af8ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @link https://searchwp.com/documentation/multisite/ | |
global $post; | |
$current_blog_id = get_current_blog_id(); | |
get_header(); | |
if ( have_posts() ) { | |
while ( have_posts() ) { | |
the_post(); | |
// Search Results may be formatted as SearchWP results | |
// because we're searching cross-site on the main site. | |
if ( 1 === $current_blog_id ) { | |
if ( $current_blog_id !== $post->site ) { | |
switch_to_blog( $post->site ); | |
$post = get_post( $post->id ); | |
get_template_part( 'search-result' ); | |
restore_current_blog(); | |
} else { | |
$post = get_post( $post->id ); | |
get_template_part( 'search-result' ); | |
} | |
} else { | |
get_template_part( 'search-result' ); | |
} | |
} | |
} else { | |
get_template_part( 'template-parts/content/content-none' ); | |
} | |
get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment