Badges WooCommerce

0.0/5
<?php
add_shortcode('sale-badge', 'wpd_badges');

function wpd_badges()
{
    global $post;
	
    // házelo to error, snad jsem to opravil - Tom
	
    $tags = get_the_terms($post->ID, 'product_tag');
	
	//var_dump($product->get);
	
    $list = "nt" . '<ul class="product-tags">';


    if ($tags) {


        foreach ($tags as $tag) {


           // $term_link = get_term_link($tag->term_id, $taxonomy);
            $name = apply_filters('the_title', $tag->name);
            $list .= "ntt" . '<li class="' . $tag->slug . '"><a class="category_links" href="' . '/tag/' . $tag->slug . '">' . $name . '</a></li>';
        }
    }

    $list .= "nt" . '</ul>';

    return $list;
}

Comments and reviews

{{ reviewsTotal }} Review
{{ reviewsTotal }} Reviews
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}

Description

This snippet displays product tags as badges.

Author

Tags