Created
March 15, 2017 19:35
-
-
Save jchristopher/9943a53a3965b9d227b02123f96ed60a to your computer and use it in GitHub Desktop.
Tell SearchWP to index term meta
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 | |
function my_searchwp_indexer_taxonomy_term( $term, $context ) { | |
$taxonomy = 'my_taxonomy'; | |
$term_meta_key = 'my_term_meta_key'; | |
if ( $taxonomy !== $context['taxonomy'] ) { | |
return $term; | |
} | |
$term_meta = get_term_meta( $context['term']->term_id, $term_meta_key ); | |
$term .= ' ' . implode( ' ', $term_meta ); | |
return trim( $term ); | |
} | |
add_filter( 'searchwp_indexer_taxonomy_term', 'my_searchwp_indexer_taxonomy_term', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment