Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Last active April 20, 2022 09:56
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 searchwpgists/4ae6e45e2a496a151d4e41b7aacbcc6b to your computer and use it in GitHub Desktop.
Save searchwpgists/4ae6e45e2a496a151d4e41b7aacbcc6b to your computer and use it in GitHub Desktop.
<?php
// @link https://searchwp.com/documentation/multisite/
// 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 sites with ID 1, 2, 3.
$args['site'] = [1,2,3];
// 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