Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created December 7, 2020 21:35
Show Gist options
  • Save jchristopher/018c63622cd488c0ed41b024336f59d5 to your computer and use it in GitHub Desktop.
Save jchristopher/018c63622cd488c0ed41b024336f59d5 to your computer and use it in GitHub Desktop.
<?php
// Give Pages extraordinary weight boost to ensure Pages show up first.
add_filter( 'searchwp\query\mods', function( $mods ) {
$post_type = 'page';
$source = \SearchWP\Utils::get_post_type_source_name( $post_type );
$mod = new \SearchWP\Mod( $source );
$mod->weight( function( $runtime ) use ( $source ) {
return "IF( {$runtime->get_foreign_alias()}.source = '{$source}', '999999999999', '0' )";
} );
$mods[] = $mod;
return $mods;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment