Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created June 3, 2020 14:12
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/5c36ae15ae9608a6ff31ebc029b870eb to your computer and use it in GitHub Desktop.
Save jchristopher/5c36ae15ae9608a6ff31ebc029b870eb to your computer and use it in GitHub Desktop.
<?php
add_filter( 'searchwp\query\mods', function( $mods ) {
if ( ! isset( $_GET['my_mod_trigger'] ) ) {
return $mods;
}
// Exclude Posts 97 and 188 from search results.
$source = \SearchWP\Utils::get_post_type_source_name( 'post' );
$mod = new \SearchWP\Mod( $source );
$mod->set_where( [ [
'column' => 'ID',
'value' => ['97', '188'],
'compare' => 'NOT IN',
'type' => 'NUMERIC'
] ] );
$mods[] = $mod;
return $mods;
}, 30, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment