SearchWP Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP’s many hooks

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
Key Type Value
taxonomy String Taxonomy name
post_id Integer Post ID
post_type String Post Type
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.

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

How to use this code