Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created March 15, 2017 19:35
Show Gist options
  • Save jchristopher/9943a53a3965b9d227b02123f96ed60a to your computer and use it in GitHub Desktop.
Save jchristopher/9943a53a3965b9d227b02123f96ed60a to your computer and use it in GitHub Desktop.
Tell SearchWP to index term meta
<?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