So I tried creating some code that will display an icon on a post depending on the category. I tested it and it just brings up the alt text, the img element gets displayed in the code and the directory is correct, but no image? Is there something I’m missing, something I’m not doing with the images? Thank you.
foreach((get_the_category()) as $category) {
echo '<img class="catimg" src="images/cats/' . $category->cat_name . '.gif" alt="' . $category->cat_name . '" />'; }
Try this if you created images folder yourself inside the wp-content folder.
If the images are in the theme folder then you can use this: