Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created January 6, 2021 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jchristopher/b0ebc3a121efb97730a189ea00b10ed4 to your computer and use it in GitHub Desktop.
Save jchristopher/b0ebc3a121efb97730a189ea00b10ed4 to your computer and use it in GitHub Desktop.
<?php
// Limit SearchWP results to Posts and Pages.
add_filter( 'searchwp\query\mods', function( $mods, $query ) {
$mod = new \SearchWP\Mod();
$mod->set_where( [ [
'column' => 'source',
'value' => [
\SearchWP\Utils::get_post_type_source_name( 'post' ),
\SearchWP\Utils::get_post_type_source_name( 'page' )
],
'compare' => 'IN',
] ] );
$mods[] = $mod;
return $mods;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment