I need some help (I'm a big PHP noobie) to show an image like this:
<img src="www.mysite.com/IMAGE.jpg" />
I would like "IMAGE" to be replaced by the actual category name of the specific post. I tried the following snippets, found on Codex and on this forum, with no luck (they all result in "www.mysite.com/.jpg"):
<?php echo $cat->category_nicename; ?>
<?php echo $post->cat_name; ?>
<?php echo $category->cat_name; ?>
<?php get_the_category( $id ) ?>
<?php echo $post->cat_name;?>
<?php echo $category->cat_name;?>
Only this one worked, but showed me only one post and broke the site layout:
<?php foreach((get_the_category()) as $category) { echo $category->cat_name; } ?>
Any other suggestions? Many thanks