Открыть документацию по функции
get_the_terms(), найти фразу "Array of WP_Term objects on success, false if there are no terms or the post does not exist, WP_Error on failure." и добавить проверку:
<?php
$cur_terms = get_the_terms($post->ID, 'metki');
if (is_array($cur_terms) && !is_wp_error($cur_terms)) {
foreach ($cur_terms as $cur_term) {
$term_link = get_term_link((int) $cur_term->term_id, $cur_term->taxonomy);
// If there was an error, continue to the next term.
if (is_wp_error($term_link)) {
continue;
}
echo '<a href="' . esc_url($term_link) . '">' . $cur_term->name . '</a> ';
}
}
?>