searchwp\source\post\attributes\taxonomy\term
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\terms
to filter all terms at once.
Parameters
Type | Parameter | Default | Since | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
\WP_Term | $term |
Term being indexed | 4.0.0 |
||||||||||||
Array |
$args
|
4.0.0 |
Examples
All hooks should be added to your custom SearchWP Customizations Plugin.
Customize taxonomy term before it is indexed
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 | |
// Customize taxonomy term before it is indexed by SearchWP. | |
add_filter( 'searchwp\source\post\attributes\taxonomy\term', function( $term, $args ) { | |
// Add 'coffee' to specific term name so it is searchable. | |
if ( 'My Custom Term' === $term->name ) { | |
$term->name .= ' coffee'; | |
} | |
return $term; | |
}, 20, 2 ); |