Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Created March 16, 2022 17:38
Show Gist options
  • Save searchwpgists/8ebeee0696a2ab16fd5bc62765c7228e to your computer and use it in GitHub Desktop.
Save searchwpgists/8ebeee0696a2ab16fd5bc62765c7228e to your computer and use it in GitHub Desktop.
Prevent specific Category from being indexed with posts in SearchWP
<?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