开发者

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

开发者 https://www.devze.com 2023-04-06 06:22 出处:网络
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 tha

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

精彩评论

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