Bild neben jedem Tag anzeigen

Avatar of Chris Coyier
Chris Coyier am
<?php
$posttags = get_the_tags(); // Get articles tags
$home = get_bloginfo('url'); // Get homepage URL

// Check tagslug.png exists and display it
if ($posttags) {
 foreach($posttags as $tag) {
       $image = "/images/tag-images/$tag->slug.png";

       if (file_exists("images/tag-images/$tag->slug.png")) {
         echo '<a href="' . $home . '/tag/' . $tag->slug . '" /><img title="' . $tag->name . '" alt="' . $tag->name . '" src="' . $image . '" /></a>';

       // If no image found, output something else, possibly nothing.
       } else {
         echo '<p>Not found</p>';
       }
  }
}
?>

Dieser Code gehört in die Schleife. Er sucht in einem bestimmten Verzeichnis nach Bildern, die den Slugs von Artikel-Tags entsprechen, zeigt sie an und verlinkt sie mit dem entsprechenden Tag-Archiv.