Index only child taxonomy terms

We previously demonstrated how to index only top-level taxonomy terms.

There are actually 2 ways to index child terms. If using the Checkboxes facet type, there is a Parent term setting where you can enter the ID of the parent term.

For more granularity, you could use the facetwp_index_row hook instead. Add the following code to functions.php file, replace “categories” with your facet name, and Re-index.

function index_child_terms( $params, $class ) {
    if ( 'categories' == $params['facet_name'] ) {
        if ( 0 == $params['depth'] ) {
            return false; // don't index top-level (depth = 0) terms
    return $params;
add_filter( 'facetwp_index_row', 'index_child_terms', 10, 2 );

Notice how we’re simply checking $params['depth'] to determine whether a term is a parent or child. Returning FALSE within that function prevents the term from getting indexed.