Do you want to set a maximum number of tags for WordPress posts?
Tags are a great way to organize your content, but a post with lots of tags can look confusing or overwhelming to readers. This can be a problem if you accept guest posts or work with lots of different authors.
In this article, we will show you how to set a maximum number of tags for WordPress posts.
Why Set a Maximum Number of Tags in WordPress?
Tags help to organize your content so visitors can find related posts more easily. However, some authors may add lots of tags in an attempt to improve the site’s SEO.
This can make your content more confusing to readers and stop them from finding related content. A large number of tags may also make your site look messy and unprofessional.
For that reason, we recommend using no more than 10 tags per post.
If you manage a multi-author blog or accept guest posts, then it’s a good idea to limit how many tags authors can add to each post.
With that being said, let’s look at how to set a maximum number of tags on your WordPress blog. Simply use the quick links 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.
This includes setting a limit on the number of categories and tags that authors can add to each page or post.
For this guide, we will be using the free version of PublishPress Checklists since it has all the features we need. However, there’s also a premium version available that offers more features like checklists for WooCommerce products.
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.
Upon activation, you will need to select Checklists in your WordPress dashboard and then find the ‘Number of tags’ section.
In the ‘Max’ field, type in the maximum number of tags an author can add to a single post.
You can also optionally type in a minimum number of tags.
With that done, open the dropdown that shows ‘Disabled’ by default and choose either ‘Recommended’ or ‘Required.’
If you choose ‘Required’, then guest bloggers and authors won’t be able to publish a post with more than the maximum number of tags.
However, if you select ‘Recommended’, then authors get a warning but can still go ahead and publish the article, as you can see in the following image.
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 type the user role into the ‘Who can ignore this task?’ box. Then, select the right role from the dropdown menu when it appears.
At this point, you may want to add more tasks to your checklist. For example, you can set a maximum and minimum number of characters for the post excerpt or check that all images have image alt text.
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 you go beyond the limit, you will see a warning message in the checklist. In this way, you can improve the editorial workflow and only publish posts with the correct number of tags.
Method 2: Show a Limited Number of Tags for 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 website. This is a good option if you use tags to organize your content in the WordPress 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.
Often, you will find guides with instructions to add custom code to your site’s functions.php file. However, this isn’t recommended, as any mistakes in the code can cause common WordPress errors or even break your site completely.
That’s where WPCode comes in.
This free plugin makes it easy to add custom CSS, PHP, HTML, and more to WordPress without putting your site at risk.
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.
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 completely disable comments, upload file types that WordPress doesn’t usually support, disable attachment pages, and much more.
To create a snippet, just hover over ‘Add Your Custom Code’ and then select ‘Use snippet.’
To start, type in a title for the custom code plugin. 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 are ready to make the code live, you must 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.
Now, WordPress will limit the number of tags it shows on your website.
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 how to make online money blogging with WordPress or see our expert picks for the best SEO 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.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Shaikh Sufiyan says
How much tags do better on a post.
Donna Cohen says
Please explain how tags help me with SEO.