hide_empty
hides terms that have no posts attached to them. You’ve got a page with no ht_kb_tags
attached to it, if I’m understanding the question correctly.
Since get_the_terms()
returns false
if there are no terms, you should be able to prevent the foreach()
with an if()
statement:
$mget_site_url = get_site_url();
//This gets me all the correct terms...
$mget_the_terms = get_the_terms(get_queried_object_id(), 'ht_kb_tag');
if ( ! empty( $mget_the_terms ) ) {
echo __( 'Tagged: ', 'knowall' );
foreach ($mget_the_terms as $keygroup => $valuegroup) {
foreach ($valuegroup as $key => $value) {
if (($key == 'name') && ($value != 'layout-wide')) {
//link the terms
echo "<a href="https://wordpress.stackexchange.com/questions/398335/{$mget_site_url}/tags/{$value}" rel="tag">{$value}</a>";
}
}
}
}