WP Limit Tags

Working on a recent project in collaboration with Keith Devon, we needed a way in which to limit the number of tags which could be applied to a post – one of the clients requirements. Therefore we set about a way to do this and produced the WP Limit Tags WordPress plugin.

The plugin, on the WordPress repository for download from your WordPress admin, creates a small settings screen. Here you can set the number of tags that are allowed and tick the post types you wish the functionality to be active on.

WP Limit Tags Setting Screen
The WP Limit Tags settings screen.

It is worth noting that at the moment the functionality works on any taxonomy which is non-hierarchical, such as post tags. Maybe in the future it would be good to be able to add different settings for the different post types and taxonomies.

Below is a short video which shows what the plugin does:


Download the WP Limit Tags WordPress plugin.

Alter The WordPress Tag Cloud Widget Output

WordPress provides a handy little widget where you can add your sites tags to a widgetised area and then are shown a tag cloud type format. However the output of this tag cloud cannot be controlled, like it can with the wp_tag_cloud() function. Having wanted to change the output I set about trying to achieve this. In this post I will outlined how to alter the output of the tag cloud widget in WordPress.


The key to altering such things as this is to follow the WordPress golden rule which is never to edit the core files. Therefore to overcome this problem we need to look at the core files themselves for code which will allow us to manipulate the output of the widget without actually altering the core code.

Looking in the wp-includes folder of WordPress core we see a file named default-widgets.php. It is in this file where the Tag Cloud widget code is sourced. Looking at the code we can see that WordPress applies a filter to the arguments it supplies to the wp_tag_cloud() function. This filter is named widget_tag_cloud_args.

Therefore we can use this to manipulate the output of the tag cloud before it is outputted to the browser. The example below allows us (for example) to set the max and min font size for tags outputted.

[wpmark_gist id=”06c3402bd55e6288b9ea”]

This is a good example of WordPress’ extensibility, something which I will be speaking about at WordCamp Manchester at the end of June.