WP Snipp Ninja

Limited Number of Tags after Posts in your Custom WordPress Theme

Author: WordPress Snippets | Posted on: August 8, 2018 |

Snippet: How to limit the number of displayed tags in your post template?

If you want to limit the number of tags you display after/before your post add the following snippet code to your functions.php file at the bottom of the file. With this simple WordPress snippet, you can tell the WordPress to limit the Number of Tags in your post page single.php template.

Add the following code in functions.php to limit the number of tags in your post

function limit_to_five_tags($terms) {
return array_slice($terms,0,3,true);

<!--- This will limit the number of tags to three (3) --->

Add the following code in your single.php where you want to display and limit post tags to 2-3

<!--- This code you should add in your Loop in single.php file --->
<?php the_tags() ?>


About the Author

 WordPress Snippets

Hello my name is Dimitar Krumov I am from Sofia Bulgaria but live in Varna on the Black Sea coast.I am a Web Developer since 2002 working in different Web Projects most of them are international and business-related. Some of my knowledge and skills but not limited to WordPress, HTML, CSS, Google Stack, Analytics, SEO and more..

Follow WordPress Snippets on Social Media

Leave a Reply

Your email address will not be published. Required fields are marked *