开发者

in wordpress, how do I add tags to the divs Class

I want to add the post tags into its div class so I can add开发者_开发技巧 specific CSS for different types of tags.


If you want to output the tag name(s) of the article being viewed into a div, do that :

<div class="
<?php
$posttags = get_the_tags();
if ($posttags) {
  foreach($posttags as $tag) {
    echo $tag->name . ' '; 
  }
}
?>
">
...
</div>

If you want to output the tag name that's being display (let's say the tag's page), do that :

<div class="<? echo single_tag_title(); ?>">
.....
</div>


Agreeing with mrtsherman, this question is vague, but if your wanting to name a class you would simply do something like

<div class="the-name-you-want">
</div>


Pass in argument on single_tag_title tag.

single_tag_title("<div class="header">");

Its perfectly works on my site.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜