Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides


  1. mahmood dabestani says:

    this post was very useful.
    But I’m going to create a single page like contact page that it has descriptions about one of my products.
    how can I add my favorite tags about that descriptions in my page?
    in other word how can I add my favorite tags in a single page?
    thank you so much.

  2. joni says:

    How for showing random tags?
    example: in my posting blog have 20 tags,
    And i want showing tags number 1, tag number 6, tag number 5,
    and another post have 20 some tags,
    and i want showing tags number 7, 17, 3.

  3. Hector P says:


    How can I do this “limit the usage of tags”. I want only 3 tags per post/product. And if I select a 4, the number is erased.

    Thank you!

  4. Gabrielle says:

    Hi, how can i add if is statement to this function?

    I want to show 5 tags on my main Blog Page(Static page with id=99),
    and then show all tags in single-post page
    Is it possible to combine this function, to work with post category?
    Like Above, i want 5 categories and 5 tags on main page, and full list on single-post…
    Sorry for my English ;/

    • WPBeginner Support says:

      For that you will have to edit your theme or child theme’s template file. For tags you can try this code:

      $posttags = get_the_tags();
      if ($posttags) {
      	$output = '';
      	foreach($posttags as $tag) {
      		$output .= $tag->name . ' ';
      		if( $count >5 ) break;
      echo $output;
  5. Andrew says:

    Great info. I came to this site though google search looking for an answer to another problem I need the tag pages to display their tag names as a heading for their individual tag pages. Is there any theme that does this? I am currently using the Divi theme and that feature is not available.

  6. Mehmet Çağatay says:

    How to print the labels at random?
    For example, 5 out of 10 have a label that is shown on a random

  7. Jill says:

    Just FYI…when I pasted those 4 lines in my functions file…my entire site went blank. I about had a panic attack. My hosting company was able to get me back up.

  8. ata says:

    What about duplicate content (after Panda update) using tags as same article will be on the post and tag pages.

    Also, i read on wp forum regarding the negative impact of using excessive tags (more than 10 tags) for each post.

    • wpbeginner says:

      @ata People should not use Tags for SEO. Tags are built-in to WordPress to improve the usability of your site. You can have 500 tags for one post for all that matters. What is crucial is that you follow, noindex the tags pages. So search engines go to those pages and follow all the links, but don’t index those pages. That will solve the SEO problem. There are too many self-proclaimed SEO experts who don’t know what the heck they are doing. Putting generic statements like the ones you mentioned above are totally wrong as long as you follow what we are saying.

      • ata says:

        Actually tags does increase traffic for some sites. You can find proof on Google. Especially long tail keywords attached to a post.

        Not sure how the search engine can find your tag links if it is set as ‘noindex’. Maybe the post url but not the tag links as it doesn’t make sense.

        The ‘generic statement’ was not a all. If you read my comment, it is more of a query/question so there is no need to bite my head off.

        • wpbeginner says:

          @ata First of all let me be clear. I am not biting your head off. The frustration was expressed toward those experts that go along making generic claims like that. WordPress allows for many ways of indexation. Most folks use category as their primary method of archives. In order to prevent duplicate content, you can only use ONE primary method of archive that is indexable. All secondary methods need to be no-index in order to prevent duplicate content.

          We use Categories as our main method of archiving. If you want you can use tags as a primary source of archiving. We find that categories tend to perform better for our blogs. If you want to use tags as a primary source of archiving, then no-index categories, and date based archives. If you are the only author on the site, then you might as well no-index author archives because that will just produce duplicate content as well.Will not argue SEO theories any further in this article because this is a tutorial for design not SEO.

  9. astronyu says:

    I was looking for this. Thanks for sharing. I agree with @mrahmadawais the first method works just fine and it is simple too.

  10. Livefyre says:

    the first method is just great

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.