Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created March 1, 2021 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/eaae9852a5a49ebee11293213be58cae to your computer and use it in GitHub Desktop.
Save jchristopher/eaae9852a5a49ebee11293213be58cae to your computer and use it in GitHub Desktop.
<?php
// Tell SearchWP to search the entire Multisite network when searching on the main site.
add_filter( 'searchwp\query\args', function( $args, $query ) {
// If this is not site 1, bail out.
if ( 1 !== get_current_blog_id() ) {
return $args;
}
// Search all sites.
$args['site'] = 'all';
// Retain site info in results.
$args['fields'] = 'default';
return $args;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment