Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Created March 29, 2022 13:49
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/7ee805d05cff9ec462e77b7c8be42493 to your computer and use it in GitHub Desktop.
Save searchwpgists/7ee805d05cff9ec462e77b7c8be42493 to your computer and use it in GitHub Desktop.
searchwp\auto_update_providers hook example
<?php
// Tell SearchWP to automatically update its providers when switching sites.
// @link https://searchwp.com/documentation/hooks/searchwp-auto_update_providers/
add_filter( 'searchwp\auto_update_providers', '__return_true' );
// Retrieve results from this site.
$searchwp_site_1 = new \SWP_Query( [
's' => 'coffee',
] );
// Retrieve results from site 2.
switch_to_blog( 2 );
$searchwp_site_2 = new \SWP_Query( [
's' => 'coffee',
] );
// Restore the original site.
restore_current_blog();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment