HI!
I have looked through the forum but cannot find a similar query.
I hope I can explain this clearly:
I am working in wordpress on my layout. It is a magazine style thing and I am trying to have a little box above each article excerpt that says which kind of piece it is (ie: essay, photo-story, comment etc..).
The kind of piece is defined in the tags (the first tag for each article is going to be one of these).
I found a snippet that gets the first tag and prints the name... so far so good, and I managed to place all of that into a html span, with a class name so it works... the tag name gets displayed, and I manage to style it...
But, what I am trying to achieve is to be able to style tags differently (ex: essay with yellow background, photo-story with blue background etc...)
I would really appreciate any advice you may have on getting this to work.
I thought perhaps getting the tag name and somehow calling in into the span class tag? Not even sure this is doable...
Other idea was to just get the tag name and then if conditional statement like : if {tag name is x then span class x echo x}
or... some kind of switch statement...
But as you can probably tell by now I am not a coder... I'm just dabbling and not very good... so super confused ;-)
Thanks in advance for the help.
Etoile Maya.
Here is something I tried but it's not working... gives me error messages//
<article itemscope itemtype="http://schema.org/Article">
<?php
$posttags = get_the_tags();
$count=0;
if ($posttags) {
foreach($posttags as $tag) {
$count++;
if (1 == $count) {
'<span class=' . "$tag->name" . '>' echo $tag->name . ' ';
}
}
}
?>
</span>