You must be logged in to post


Register? | Lost Your Password?

Search Forums:


 






Wildcard Usage:
*    matches any number of characters
%    matches exactly one character

Displaying images (or text or what have you) based on tags

UserPost

7:47 am
June 2, 2010


AvondaleSteve

Member

posts 9

1

(I should say this is for 3.62 but you'll likely be able to figure out how to implement it for v.4.  And I'm sure there's a more efficient way of doing this in the back end.  But I couldn't figure it out so well.)

If your site uses tagging extensively then this might be an interesting way to add more visual information to the product page.

For instance, on my site equipment is tagged by manufacturer so this allows me to put the manufacturer's logo on each product page.  Example

So how did I do it?

1. Install and activate two plugins:
- Rich Text Tags, Categories, and Taxonomies ("This plugin offers rich text editing capabilities for descriptions of tags, categories, and taxonomies."  Basically, this is the WYSIWYG editor which you use to bring up the image.)
- Allow HTML in Category Descriptions AKA HTML in Category Descriptions ("Allows you to add HTML code in category descriptions" This is need as otherwise WP parses out all the HTML code.)

2. Add the following text to single.php.  You can add it where you think appropriate. Personally I added it immediately after the opening of the product_image DIV:

<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo tag_description($tag->term_id);
}
}
?>

3.  Add the image (or text or what have you).
- Under Posts > Post Tags, choose Edit for an already existing tag.
- You'll see the WYSIWYG editor above the Description field.  Insert an image, or text what you have just like you would on a post.

4. Party!



 

Market takes e-commerce to the next level with an easy to use, quick setup platform. Learn more or take the tour.