2011-06-22 16 views
0

投稿に関連付けられたタグを取得してdivのクラスとして使用するために、post_tags参照を使用しようとしています。私はちょうどそれを働かせるように思わない...任意のアドバイス?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 . ' '; 
    } 
    } 
} 
?> 

をしかし、それだけで、私はそれらすべてを表示するように変更することができますどのように、最初のタグを示しています。

答えて

1

は、この行(と同等の右中括弧)を取り払う試してみてください。

if (1 == $count) {

関連する問題