Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created June 3, 2020 13:54
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/e7daa4a89d274182a2bfea88be67972c to your computer and use it in GitHub Desktop.
Save jchristopher/e7daa4a89d274182a2bfea88be67972c to your computer and use it in GitHub Desktop.
<?php
// Add relevance weight to a single SearchWP Source (Posts).
add_filter( 'searchwp\query\mods', function( $mods ) {
global $wpdb;
$mod = new \SearchWP\Mod();
$source = \SearchWP\Utils::get_post_type_source_name( 'post' );
$mod->weight( $wpdb->prepare( "IF(s.source = %s, 9999999, 0)", $source ) );
$mods[] = $mod;
return $mods;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment