Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created March 26, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/98ff8240d9f8897f6ed6139274529e6b to your computer and use it in GitHub Desktop.
Save jchristopher/98ff8240d9f8897f6ed6139274529e6b 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