Taxonomy image link help
-
I am trying to get post taxonomies to show up as linked images, but have hit a wall with my extremely limited PHP knowledge. I found the following code that will accomplish what I want, only with categories:
<h3><b>Posted in:</b></h3> <?php foreach((get_the_category()) as $cat) { $catname =$cat->category_nicename; echo "<a href=\"/category/"; echo $catname; echo "/\">"; echo "<img src=\"/wp-content/themes/gtd1.0/images/"; echo $catname; echo ".jpg\" alt=\"$catname category image\" border=\"0\" /></a>\n"; } ?><br />
This results in images with the same name as the category being pulled from a specified folder and being used as category page links. I tried modifying this for a “people” taxonomy:
<h3><b>Posted in:</b></h3> <?php foreach((get_the_terms($post->ID, 'people')) as $tax) { $taxname =$tax->slug; echo "<a href=\"/people/"; echo $tax; echo "/\">"; echo "<img src=\"/wp-content/themes/gtd1.0/images/"; echo $tax; echo ".jpg\" alt=\"$tax category image\" border=\"0\" /></a>\n"; } ?><br />
This returns a link to “…/people/Array” instead of a “…/people/person” result. Could anyone lend a hand and help me with the code for taxonomies? Thanks!
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘Taxonomy image link help’ is closed to new replies.