-
-
Save searchwpgists/8ebeee0696a2ab16fd5bc62765c7228e 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