• Resolved turkishjapan

    (@turkishjapan)


    Hi all.

    I have a problem.

    I would like to show just a few tags on index.php of post. Actually i want to show only 3 tags per post.

    I think we can use “get_the_tags” but i couldn’t because i am not master of WordPress ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Need to put this inside your loop:

    <?php
    $metas = '';
    $count = 0;
    
    $tags=get_the_tags($post->ID);
    if ($tags) {
      foreach($tags as $tag) {
        $count++;
        if ($count <= 3) {
          $metas .= $tag->name . ', ';
        }
      }
      echo substr($metas,0,-2);
    }
    ?>

    Thread Starter turkishjapan

    (@turkishjapan)

    Hey MichaelH!

    You are amazing! Thanks a lot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How i get only 3 tags or like that?’ is closed to new replies.