Note: You are viewing the documentation for Version 3View Version 4 Docs


View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

Available since: 2.8.7


View Parameters »

Note: Use of this hook will require a manual reindex

By default SearchWP will index the taxonomy terms associated with posts as they’re indexed if the taxonomy has been added to an engine configuration.

If you would like to index additional taxonomy term data alongside the term itself, you can use this hook:

// Index taxonomy term metadata alongside taxonomy term in SearchWP.
add_filter( 'searchwp_indexer_taxonomy_term', function( $to_index, $context ) {
$term_meta = get_term_meta( $context['term']->term_id, 'my_term_meta_key', true );
// If the metadata exists, append it to the string to be indexed by SearchWP.
return ! empty( $term_meta ) ? $to_index . ' ' . $term_meta : $to_index;
}, 10, 2 );
view raw functions.php hosted with ❤ by GitHub


Parameter Type Description
$term String

The taxonomy term

$context Array

$context['SWP'] The SearchWP instance
$context['taxonomy'] The taxonomy being indexed
$context['term'] The term being indexed

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP