Get related taxonomy of Product on Single Product WordPress

I want to display related taxonomy of Product on Single Product WordPress. Added $product->ID but it breaks the page. Without it all works but displays all taxonomy and not only related.

<?php global $product; 
    $terms=get_terms($product->ID, 'custom_features'); 

    foreach ($terms as $term) { 
        echo '<il><a href="'.get_term_link($term->slug, 'custom_features').'">'.$term->name.'</a></il>';
    }
?>

Related posts

Leave a Reply

1 comment

  1. Try this

        <?php
    $features = get_terms('custom_features');
    
    foreach($features as $feature)
        {
        $feature_link = get_term_link($feature);
        if (is_wp_error($feature_link))
            {
            continue;
            }
    
        echo '<a href="' . esc_url($feature_link) . '">' . $feature->name . '</a>';
        }
    }