Forked from jchristopher/searchwp-customizations.php
Last active
August 11, 2021 10:05
-
-
Save BrElio/0c684f8c4f1057e489101a83140c716e to your computer and use it in GitHub Desktop.
Limit SearchWP results to Posts and Pages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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