Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
30 Million+
Websites using our plugins
20+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Set Maximum Number of Tags for WordPress Posts

Do you want to limit the number of tags authors can add to WordPress posts?

Tags help organize your content and make it easier for visitors to find related posts. But when authors add too many tags, your site can end up with cluttered tag archives, inconsistent tagging, and posts that are harder to organize.

This can be especially frustrating if you accept guest posts or have multiple authors who use tags differently. Setting a maximum number of tags helps you keep your site’s content organized and maintain a consistent tagging policy.

In this article, we’ll show you how to set a maximum number of tags for WordPress posts.

How to Set Maximum Number of Tags for WordPress Posts

You can use the quick links below to jump straight to the method you want to use:

Method 1: Limit How Many Tags Users Can Add to WordPress Posts

If you want to limit the number of tags that users can add to each post, then we recommend using PublishPress Checklists. This plugin allows you to add a pre-publish checklist to the dashboard and create tasks that authors must complete before submitting the post.

One of these tasks lets you set a maximum number of categories and tags that authors can add to each post or page.

For this guide, we will be using the free version of PublishPress Checklists since it has all the features we need.

The first thing you need to do is install and activate the PublishPress Checklists plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Installing the PublishPress Checklist plugin

Upon activation, you will need to select ‘Checklists’ in your WordPress dashboard and then find the ‘Number of tags’ section under ‘Tags.’

First, open the dropdown that shows ‘Disabled’ by default and choose either ‘Recommended’ or ‘Required.’

Configuring the number of tags for WordPress posts

If you choose ‘Required’, then guest bloggers and authors won’t be able to publish a post that has more than the maximum number of tags. However, if you select ‘Recommended’, then authors will only see a warning. They can still go ahead and publish the article.

The PublishPress Checklists plugin also lets you exclude some user roles from the maximum tag rule. For example, editors might benefit from being able to add as many tags as they want.

To exclude certain users, simply click on the ‘Exclude User Roles’ box and select a role from the dropdown menu when it appears.

Excluding user roles

Now, in the ‘Max’ field, go ahead and type in the maximum number of tags an author can add to a single post. Similarly, you can also set a rule for the minimum number of tags if you want.

Setting minimum and maximum number of tags users can add to posts

If you’re considering adding a detailed publish checklist for your authors, please see our guide on how to add a blog post checklist to the WordPress editor.

When you are happy with the checklist, just click on ‘Save Changes’ to store your settings.

To see the tag limit in action, simply open any post in the WordPress content editor and then start adding tags.

When a post doesn’t meet the tag requirements you’ve set, the checklist will show a warning message.

Checklists' tag limit warning inside the WordPress content editor

Method 2: Limit How Many Tags Are Displayed on WordPress Posts

Instead of limiting how many tags authors can add to a post, you can limit the number of tags that you show on your WordPress site. This is a good option if you use tags to organize your content in the dashboard but don’t necessarily want to show all these tags to your visitors.

To limit the number of tags that appear on your website, you will need to add some custom code to WordPress.

To make sure your custom code doesn’t accidentally break your site, we recommend using the WPCode plugin. This plugin also makes sure your code snippet will be preserved even after switching to a different WordPress theme.

To start, you will need to install and activate WPCode. For more information, you can see our step-by-step guide on how to install a WordPress plugin.

Installing WPCode in WordPress

After that, go to Code Snippets » Add Snippet in the WordPress dashboard.

Here, you will see all the pre-made snippets you can add to your WordPress website. These include a snippet that allows you to exclude specific categories from your RSS feed, or even disable categories and tags completely.

To create a snippet, just hover over ‘Add Your Custom Code’ and then select ‘Use snippet.’

Add a new custom snippet in WPCode

To start, type in a title for the custom code snippet. This could be anything that helps you identify the code in your WordPress dashboard.

Next, you need to open the ‘Code Type’ dropdown menu and choose ‘PHP’.

After that, you can paste the following code into the code editor:

add_filter('term_links-post_tag','limit_to_five_tags');
function limit_to_five_tags($terms) {
return array_slice($terms,0,5,true);
}

This will display a maximum of 5 tags per post. To show a different number of tags, simply change the number 5 to anything you want.

When you’re ready to make the code live, just scroll to the top of the screen and click on the ‘Inactive’ toggle so it changes to ‘Active’. Finally, simply click on ‘Save Snippet’ to make the snippet live.

Saving custom code to show limited number of tags in WordPress

Now, WordPress will display only the number of tag links you specified on your website. Authors can still add more tags to a post, but visitors will only see the number you’ve chosen to display.

We hope this article helped you learn how to set and display a maximum number of tags for WordPress posts. You may also want to learn about WordPress post analytics or see our expert picks for the best WordPress plugins and tools.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

6 CommentsLeave a Reply

  1. This is a super tip for managing tags! Using PublishPress Checklists to set a limit on tags per post sounds like a great way to encourage authors to be more selective with tagging. This could help improve overall website organization and potentially even search engine optimization (SEO) by focusing on the most relevant keywords.

  2. I am trying to launch a second website with several other people who will act as contributors and write articles externally. Since I am trying to set some rules before the website goes live, this article is great for adhering to the principle of the maximum number of tags an article can have. I thought of setting a rule of one tag per article. Therefore, I would like to ask if my theory is correct. I am worried about content duplication. Does using only one tag have any significance for improving SEO to prevent duplication, or does it not matter much and I can afford to use more tags, for example, 3-5 as a maximum?

    • Using only one tag should not give you an SEO advantage over using a few descriptive tags and if you have an SEO plugin that will normally mark your tags properly to prevent it from being flagged as duplicate content.

      Admin

  3. it is good to have control over number of tags used in each posts.
    Setting a maximum limit not only helps in better tags organisation but also restrict to use only the important tags and not just stuffing tags with keywords.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.