Created
March 26, 2020 15:11
-
-
Save jchristopher/98ff8240d9f8897f6ed6139274529e6b to your computer and use it in GitHub Desktop.
Prevent specific Category from being indexed with posts in SearchWP
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 | |
// Prevent specific Category from being indexed with posts in SearchWP. | |
add_filter( | |
'searchwp\source\post\attributes\taxonomy\terms', | |
function( $terms, $args ) { | |
// Do not index the 'Uncategorized' term. | |
return array_filter( $terms, function( $term ) { | |
return 'Uncategorized' !== $term->name; | |
} ); | |
}, | |
20, 2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment