wp_get_post_terms
doesn’t accept 'parent'
or 'hide_empty'
parameters in it’s arguments array, only 'orderby'
,'order'
and 'fields'
but you are on the right track, simply add a conditional check before you echo out the slug:
function project_get_item_classes($post_id = null) {
if ($post_id === null)
return;
$_terms = wp_get_post_terms($post_id, 'construction_type');
foreach ($_terms as $_term) {
if ($_term->parent == 0) //check for parent terms only
echo " " . $_term->slug;
}
}