Skip to content

Instantly share code, notes, and snippets.

@djrmom
Last active August 25, 2020 16:00
Show Gist options
  • Save djrmom/03e46e7b16937052685c39d3d32eb407 to your computer and use it in GitHub Desktop.
Save djrmom/03e46e7b16937052685c39d3d32eb407 to your computer and use it in GitHub Desktop.
facetwp index only parent and one level child terms
<?php
/**
** only index parent and first level child tax terms
** must re-index after adding filter
**/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'my_tax_facet' == $params['facet_name'] && $params['depth'] > 1 ) { // channge 'my_tax_facet' to the facet name being indexed
$params['facet_value'] = ''; // skip indexing
}
return $params;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment