Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Fronted Search Setting options [esclude terms empty] › Reply To: Fronted Search Setting options [esclude terms empty]
October 10, 2016 at 4:43 pm
#10422
Hi Ernest,
This is a machine translation.
Like I said, it is strange that ‘parent’ => 0 does not work.
However I want to share the solution I found, if other users had my need.
add_filter( 'asp_fontend_get_taxonomy_terms', 'asp_filter_empty_terms', 1, 3 );
function asp_filter_empty_terms($terms, $taxonomy, $args) {
if ( $taxonomy == 'luoghi' ) {
$terms = get_terms($taxonomy, array(
'orderby' => $args['orderby'],
'order' => $args['order'],
'taxonomy'=> $taxonomy,
'parent ' => 0,
'hide_empty' => 1
));
foreach ($terms as $key =>$singleTerm) :
$term = get_term_by('id', $result->term_id, $taxonomy);
if ( $singleTerm->parent != 0 ) :
unset($terms[$key]);
endif;
endforeach;
return $terms;
}
return $terms;
}
Ticket chiuso. Thanks for the support, Claudio_