searchwp\source\post\attributes\taxonomy\terms
Since: 4.0.0
Table of Contents
Manipulate the taxonomy terms for a post prior to indexing. Applies only when the Taxonomy has been included in an Engine.
See also searchwp\source\post\attributes\taxonomy\term
to filter individual terms.
Parameters
Type | Parameter | Default | Since | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
WP_Term[] | $terms |
Taxonomy Term objects | 4.0.0 |
||||||||||||
Array |
$args
|
4.0.0 |
Examples
All hooks should be added to your custom SearchWP Customizations Plugin.
Prevent specific Category from being indexed with posts
Do not index the Uncategorized Category term when indexing.
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 ); |