Support » Plugin: WooCommerce » get_tags() without link

  • Hello,

    I want to display all my product tags without a link, just as text.
    But all the tags are also need to be displayed in differrent divs, so for example:

    <div class="tag-1">Tag-1</div>
    <div class="tag-2">Tag-2</div>
    <div class="tag-3">Tag 3</div>

    The problem is that I cannot fix this, at the moment I have the following code:

    <?php echo $product->get_tags( ' ', '<span class="tagged_as"></span>' ); ?>

    Could someone help me?

    Regards,
    Joren

    https://wordpress.org/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    You can use get_the_terms to get the list without the HTML format.

    <?php $tags =  get_the_terms( wc_get_product()->ID, 'product_tag' ); ?>
    <?php foreach ( $tags as $tag ) : ?>
    	<div class="tag-<?php echo esc_attr( $tag->slug ); ?>"><?php echo $tag->name; ?></div>
    <?php endforeach; ?>

    Hope that helps.

    you are the savior of mankind

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_tags() without link’ is closed to new replies.