SearchWP

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
Key Type Value
name String Term name
slug String Term slug
desc String Term description
4.0.0

Examples

All hooks should be added to your custom SearchWP Customizations Plugin.

Customize taxonomy term before it is indexed

<?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 );

How to use this code