SearchWP

This Documentation is for SearchWP Version 3

Available since: 2.8.7

searchwp_indexer_taxonomy_term

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:

<?php
// 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

Parameters

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

[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]
[wpforms id="3080"]