Last active
April 19, 2019 14:08
-
-
Save jchristopher/652bdc438d919d4846b63daf8ed9bf0f to your computer and use it in GitHub Desktop.
Index taxonomy term metadata alongside taxonomy term in SearchWP
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 | |
// 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment