Show Product Tags as Links

This page is in the Code Graveyard where I lay to rest snippets of code that I don't use anymore. Some have lost their usefulness due to the evolving nature of the web, while others have been replaced with better code. "Be Ye Warned!"

This is for use with WP e-Commerce plugin. Use this code if you want to show the “Product Tags” as links. It works in the single product page container in wpsc-single_product.php.

A Caveat to Using Tag Links In WP e-Commerce

One drawback is that, as of WP e-Commerce version 3.8.8, it does not support pagination for Tags. Tags don’t function the same exact way as “Product Categories”, so extra code would have to be written to support pagination for Tags.

But for now, this code is useful if you have less products per tag than per page, so that pagination will not be an issue. You can increase your number of “products per page” in the ‘Store Settings’ in the WordPress dashboard.

And now the code. Place it within the product loop in wpsc-single_product.php.


<!--  show product tags as links -->
<p class="tagged-with">See Similar Items: 
<?php $wpsc_product_tags = get_the_product_tags( wpsc_the_product_id() );
if ($wpsc_product_tags) { 
      foreach ($wpsc_product_tags as $wpsc_product_tag) {
       $tagname = $wpsc_product_tag->name;
       $tagid = $wpsc_product_tag->term_id;
       $taglink = get_term_link( $wpsc_product_tag->slug, $wpsc_product_tag->taxonomy );
       echo '<a href="'.$taglink.'">'.$tagname.'</a>, ';
      }
}  ?>
</p>


See more: ,

We've 4 Responses

    • April 18th, 2013 at 8:55 pm

      I have not used WPEC or looked at its code in about a year. Unless they’ve changed the name, the taxonomy for product tags is: product_tag .
      So create a template file called taxonomy-product_tag-{your-particular-tag}.php and it will be used automatically when viewing that tag’s archives.
      Replace the curly brackets and the text inside them with the slug of your particular tag. Hope this helps.

      Isabel

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]