0
我正在尝试使用post_tags引用来获取与帖子相关联的标签并将其用作div的类。我似乎无法得到它的工作......任何建议?wordpress - post_tags不输出标签
<div id="workarchives_items">
<?php
global $post;
$myposts = get_posts('numberposts=100&offset=news&category_name=portfolio');
foreach($myposts as $post) :
setup_postdata($post);
?>
<div class="workitem <?php $posttags = get_the_tags(); ?> ">
<div class="workitem_photo"><?php the_post_thumbnail('150,200'); ?></div>
<div class="workitem_title"><?php the_title();?></div>
<div class="workitem_description"><?php the_excerpt(); ?></div>
<a class="workitem_projectdetails" href="<?php the_permalink(); ?>" style="display:none;">Project Details</a>
</div>
<?php endforeach; ?>
</div>
我用这个:
<?php
$posttags = get_the_tags();
$count=0;
if ($posttags) {
foreach($posttags as $tag) {
$count++;
if (1 == $count) {
echo $tag->name . ' ';
}
}
}
?>
但它只显示第一个标签,我怎么可以修改它来显示他们。