Coming uo with solutions to WordPress needs often means finding a different tree to bark at. I’m never surprised to discover along the way some dusty niche in the code.

For example, in the tale I spin out here, I never knew there was a limit for the number of tags the default tag cloud widget can show. And was it usually happens, this came via a request for one of my SPLOT themes where it’s being used in a way I never thought.

In this case, the situation is a course where students in multiple sections are contributing drawings to a TRU Collector powered site hosted at the OpenETC (see this clever SPLOTTING at Get Cape. Wear Cape. Fly). In the true SPLOT spirit of students not having to attach their name publically to submitted assignments, the instructor has assigned each student a unique tag they are asked to use on each submission.

The email I got came in with s subject line “SPLOTs not showing all tags”.

The problem arose because the instructor noticed that not all of the tags were listed on the site’s tag cloud widget sidebar. And hah, I never knew this, but this widget caps the number of tags shown at 45. Why? I can only guess it has something to do with not letting a widget get to take up gobs of space.

If it was a self hosted site, one way around is a different plugin, something like Ultimate Tag Cloud Widget which I used once. Maybe not, it’s pretty ancient. But plugins are less viable in a shared hosting environment, and often just end up being more piles of code than you need.

My first thought was to make used of some found code to change that number (bless the WordPress filer system), and I could see it being a new theme option.

It helps to let ideas simmer before jumping too quickly to a fix. What the need was not as much more tags in the sidebar, but actually what makes more sense is a means to generate in a page a list of all tags, something to be used to review student work.

So I decided to roll a shortcode function into my theme, that allows a site owner to create a list of tags but with options to display in many ways.

The code is simple and came mostly from reading up in the WordPress Codex on the get_tags function (more or less a version of get_terms()).

The most simple version using all the defaults lists all tags used in alphabetical order, each one linked to the archive, and includes the number of items/posts using it (see the list of All Stories for Get Cape. Wear Cape. Fly).

[[taglist]]

You can see it in action on a test page over at https://splot.ca/collector/taglist/

One could list them instead in the order of most used to least:

[[taglist orderby="count" order="DESC"]]

And then by limiting the number shown, it could be a top 10 tag list.

[[taglist number="10" orderby="count" order="DESC"]]

This now seems much more useful than a tag cloud. And I am pretty sure the cutoff at 45 is not for the mst used, just the first 45.

This feature is available now in the latest version of the TRU Collector in GitHub and because I could, it is available to sites hosted at the OpenETC. I will likely toss the code into some of the other SPLOTs.

Thoughts, ideas, requests or even random GIFs of dancing elephants are welcome. Better yet, asl me for a new feature… you just might get it.


Featured Image:

Make Sure All Your Posts Have Tags
Make Sure All Your Posts Have Tags flickr photo by cogdogblog shared into the public domain using Creative Commons Public Domain Dedication (CC0)

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Profile Picture for Alan Levine aka CogDog
An early 90s builder of the web and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person.

Comments

Leave a Reply

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