patrick
patrick

Reputation: 657

wordpress - post_tags not outputting tags

I am trying to use the post_tags reference to get the tag associated with a post and use it as a class for a div. I just cant seem to get it working... any advice?

<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>

I've used this:

<?php
$posttags = get_the_tags();
$count=0;
if ($posttags) {
  foreach($posttags as $tag) {
    $count++;
    if (1 == $count) {
      echo $tag->name . ' ';
    }
  }
}
?>

But it only shows the first tag, how can I modify it to show them all.

Upvotes: 0

Views: 169

Answers (1)

john010117
john010117

Reputation: 201

Try getting rid of this line (and the equivalent closing curly brace):

if (1 == $count) {

Upvotes: 1

Related Questions