get_terms() doesn’t return empty terms even though hide_empty is false

You use the hide_empty argument for $terms, but not for $this_term inside your loop.

Also, with the way you’re generating your select, it would be a lot more efficient to just query top-level terms for the main loop:

$terms = get_terms( 'device', array( 'hide_empty' => false, 'parent' => 0 ) );

And then drop if($term->parent == 0) {... inside your loop.

Leave a Comment