I want to display product assigned terms, wrapped in link/anchor MarkUp, in my sidebar on a page as a widget. I am not getting the correct tag URL. Code returns visited product URL instead of listed tags URL.
Here is the problematic part of the code. What is the correct use of get_the_terms()
?
$custom_terms = get_the_terms( 0, 'product_tag' );
if ( $custom_terms ) {
foreach ( $custom_terms as $custom_term ) {
echo '<a href="'
. esc_url( $term_link )
. '" style="font-size: 8pt;">'
. $custom_term->name
. '</a>';
}
}
I guess that something i wrong with esc_url( $term_link )
, but what?
$term_link
is still not set. The correct snippet appears to have never been posted.