I’m looking for a way of building an if/else statement that will display an image if one exists in a theme folder, or display a default image otherwise.
So, for instance, I have images for some of my tags, but not all of them. I want a piece of script that will check for a file named after the tag slug (or tag ID) and display it. If there’s no image, then it displays some other standard image.
The closest I’ve come is this code from the WordPress site, but it’s trying to show multiple images because of the “foreach” line. I have no clue what the alternative is. Anyone have some advice?
Please keep in mind the code will be in the tag.php file.