Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active May 24, 2020 12:00
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/2065884eb2cdcb2e4ce82e0b70a48099 to your computer and use it in GitHub Desktop.
Save jchristopher/2065884eb2cdcb2e4ce82e0b70a48099 to your computer and use it in GitHub Desktop.
<?php
// Retrieve Source name to use with Mod.
$source = \SearchWP\Utils::get_post_type_source_name( 'post' );
// Build Mod to exclude Post ID 145 and Post ID 211.
$mod = new \SearchWP\Mod( $source );
$mod->set_where( [ [
'column' => 'id',
'value' => [ 145, 211 ],
'compare' => 'NOT IN',
'type' => 'NUMERIC',
] ] );
// Execute search for 'coffee' using Mod.
$search = new \SearchWP\Query( 'coffee', [
'mods' => [ $mod ],
] );
$results = $search->results; // Array of results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment