Examples of Applications and Custom Code Snippets

On this page you find some examples of using the Tag Group plugin with own code. These are mainly functions that I provided on the support forum.

I hope that this will be helpful for people who have a particular requirement and need some inspiration on how to tackle the problem.

I don’t maintain this page regularly and I don’t check third party code. Please consider this an unsupported collection of hints that might require knowledge of PHP and your own work.

You may also get some ideas on the pages about available hooks (filters and actions): free plugin, premium plans

If you need someone to help you add and customize the code, there are sites where you can hire developers and web designers, for example Codeable or Fivver.

1. Filter posts on category pages

If you want to add an additional filter to your category pages and display only posts with tags that are members of particular tag groups, add the following code into the function.php of your active theme. You will need to pre-define your choice for each combination of category id => tag group id. If you display a page that is not in the array or if you choose a tag group that contains no tags, then posts will not be filtered.

2. Display a different tag cloud on each category page.

Add this into your theme’s category page (could be archive.php or category.php or others) to add a tag cloud of a particular tag group that can be pre-defined per category. The pattern in the array $term_group is category id => tag group id.

3. Display tag cloud on tag page for given group

Add this to your tag (or category, term ..) page (often this is archive.php) to display a tag cloud for the tag group that the displayed tag is a member of.

4. Same styling for all tags of same group

Add the following style sheet (e.g. into style.css) and refresh the cache. This will style the tags in the tag cloud, all tags of the first group red and all of the second group green.

5. Custom permalink bases for tags

Since the plugin doesn’t offer (yet) to automatically change tag bases according to the groups of the respective tags, you may want to try instead the Custom Permalinks plugin. (many thanks to Wolf Larsen for the hint!)

6. Group name on top of tag page

Insert the following code into the template (usually tag.php):

7. Display tags in columns

Alternatively you can use the Table Tag Cloud of the premium version.

8. Display tags in columns, responsive version

Alternatively you can use the Table Tag Cloud of the premium version.

Experiment with the min-width values to find what suits your website.

9. Use Tag Groups with a 3d-cloud

This can be achieved by modifying the plugin html5 Tag Cloud (Link seems to be broken. Try here). In that plugin you edit the file tagCloud-html5.php and replace the function wp_tag_cloud() by echo tag_groups_cloud(…). Inside the brackets you use the parameters for Tag Groups.

10. Add a category image (icon) to each tag

The following code uses the plugin Categories Images. The function will be called for each tag and it returns the modified HTML of the piece prepended to each tag. You can also use other ways to supply an image URL instead of z_taxonomy_image_url().

11. Remove a piece from tag names

The following code removes strings from the beginning of tag names. It works only for tag clouds and tag lists that are created by the Tag Groups plugin.