Use Taxonomy Term slug to populate taxonomy.php
-
Hello all,
I feel a touch sleazy with this post, as I feel like I should know how to do this!
I’ve dug around and managed to mangle together the following bit of code:
<?php $term = $wp_query->queried_object; $tempDirectory = get_bloginfo('template_directory'); echo '<img src="'.$tempDirectory.'/images/specialties-'.$term->slug.'.png" width="1015" height="327" alt="Specialties: '.$term->name.'" />'; ?>
This is placed in my taxonomy.php page. It uses the current taxonomy term’s slug to pull in the correct image associated with that term, and uses the name to populate the alt=”” value. Works great.
What I’d like to to is make this conditional such that if the image requested does not exist, display a default image instead.
Anyone have ideas on how to build this if else?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Use Taxonomy Term slug to populate taxonomy.php’ is closed to new replies.