Adding Some Polish (small features) to the Three Main SPLOTs

Like some shiny dress shoes, my SPLOT themes just got a wee bit of polish based on some needs others had. I also made an effort to make sure the three main ones TRU Writer, TRU Collector, and SPLOTbox all got the same shine.

This also reinforces what has been true since the first SPLOTs rolled out- that many of the best features come when people have uses I never imagined.

Let’s crack open that can of polish and see where it was used.

More Sort Options

By default in WordPress, with its roots as blogging platform, all the views of posts (or items submitted to a SPLOT) are always listed in reverse chronological order, newest stuff first. A few years ago I added to TRU Collector a theme option to that items could be sorted also alphabetically and by allowing a both ascending and descending order, this means all content could be sorted:

  • By Date, descending (default, reverse chronological, new stuff first)
  • By Date, ascending (oldests tuff first, not sure how this would be ever used)
  • Alphabetical by title, ascending (A-Z)
  • Alphabetical by title, descending (Z-A)

This came by request from Daniel Villar-Onrubia who had started the clever idea to use TRU-Collector as a site for students in a class (or later, people attending an event) could share bios.

That was the only SPLOT I provided this option.

But then came the capes. Just this semester, Jessica Motherwell MacFarlane has been doing some amazing work where students create a series of 8 hand drawn comics to demonstrate steps in a personal development process (see Get Cape. Wear, Fly — the psychology of making one change). She had devised a setup where students, in SPLOT like fashion, did not use their names, but instead would use a unique tag she assigned so that each student’s work was available at a tag url.

The reverse chronological order is fine for the home page, so you can see newest work first. But when viewed as a tag, a student’s work would be in the order of 8,7,6,5,4,2,1 when as comics, that is reversed. A change I have rolled into all three splots, allowed her to to set the order for tag archives only to be normal chronological (sorted by date, ascending). Look at an example to see this in play -the layout can vary depending on the amount of text in the title affecting how the boxes are laid out, so it’s not a perfect comic strip, but this is closer to the order of the comic panels tis student submitted.

This is the new theme feature, on all three SPLOTs, that the sorting can be chosen as outlined above, but you can also define where this alternate sorting is used:

  • Everywhere on the site
  • Only on the home page
  • Only on category archives
  • Only on tag archives
  • Only on tag and category archives
Sorting options- set te oder of published items on home page and archives, with the sort options described above as three settings
In this example, sorting is only applied to the home page, so that items are listed in alphabetical order. In category and tag archives, the display will be normal reverse chronological.

For those that like code, this is done with a hook in the theme for pre_get_posts as we need to interact with the query early in the flow of things. The function that manages the different cases has a bit of repetition to it, so sue me. This is the code from TRU Writer:

add_action( 'pre_get_posts', 'truwriter_order_items' );

function truwriter_order_items( $query ) {

	// check for not being an admin screem and a main query
	if ( !is_admin() && $query->is_main_query()  ) {

		// test on the settings
		switch (truwriter_option('sort_applies')) {

			case 'all':
				// use sorting on home, all archives, and search results
				if (  $query->is_home() OR $query->is_archive() OR $query->is_search() ) {

			case 'front':
				if (  $query->is_home() ) {
					// use sorting on home only
			case 'tag':
				if (  $query->is_tag() ) {
					// tag archive
			case 'cat':
				if (  $query->is_category() ) {
					// category archive
			case 'tagcat':
				if (  $query->is_tag() OR $query->is_category() ) {
					// any archive that made it this far

		} // switch

	} // if  main query


function splotbox_query_set ($the_query) {
	//utility to set the query as per the theme settings
	$the_query->set( 'orderby', truwriter_option('sort_by')  );
	$the_query->set( 'order', truwriter_option('sort_direction') );


A Shortcode to Display All Tags

Jessica’s sites also introduced a problem I never knew about- because of the number of students in her class, the WordPress tag cloud widget was not showing them all. As it turns it, the widget is hard wired to list only 40 tags, and she had upwards of 60? 70? I thought about adding an option to increase the number the widget could show, but this might have made the TRU Collector sidebar blow up to take up a ton of space.

I came up with an alternative approach, I created a [[taglist]] shortcode that could be used on a page to have a full listing of all tags. The default is to list all tags, in alphabetical order– see how the Cape site uses it to list the full collection.

A good shortcode though can offer options to fine tune what it does. These are all the options that can be passed.

  • number=10 limit to ten tags (default=0 or all tags)
  • show_count=false hides the display of the number of times tag used (default=true)
  • mincount=2 will only show tags used 2 or more times (default=1)
  • orderby="count" to order results by the number of times tag used (default=”name”)
  • order="DESC" to list in descending order (default=”ASC”)
  • hide_empty=0 to list tags not used (default=1)

Examples might include:

  • [[taglist mincount="5"]] List in alphabetical order, but only show tags used 5 or more times
  • [[taglist orderby="count" number="10"]] Show the top 10 tags used, listed in order of most first

This might not be of wide use, but it was fun to make it flexible. I guess I should make a similar one for categories (?).

For the code minded, here it is:

add_shortcode("taglist", "splotbox_taglist");

function splotbox_taglist( $atts )  {
  	extract(shortcode_atts( array( "number" => '0', "show_count" => true, "orderby" => 'name', "order" => "ASC", "hide_empty" => 1, "mincount" => '1' ), $atts ));

  	// set args
	$tags = get_tags(array(
	  'number' => $number,
	  'count' => $show_count,
	  'orderby' => $orderby,
	  'order' => $order,
	  'hide_empty' => $hide_empty,


	if ($tags) {
    	$output .= '
    '; foreach ($tags as $tag) { // show if the count is more than the minimum set in options if ($tag->count >= $mincount) { $output .= '
  • '. $tag->name .''; if ($show_count) $output .= ' (' . $tag->count . ')'; $output .= '
  • '; } } $output .= '
'; } else { $output = '

No tags found!

'; } return $output; }

A Shortcode to Display Total Count of All Items

This one is pretty simple, but can be used in widgets or About pages where you would like to say “This collection includes XX published things”. It’s already included in the TRU Collector theme beneath the title, but I made it available should it be wanted anywhere else.

The usage is most basic, just enter [[splotcount]] where you want the number to appear (you can wrap that in a bold tag in the editor).

Really simple code here… no options included.

add_shortcode('splotcount', 'splot_count_splots');

function splot_count_splots() {
	return wp_count_posts()->publish;

I find it useful to dynamically display how many items there are.

Categories and/or Tags for Admin Use Option

These next few bits of SPLOT and Polish came from questions from Suzanne at Lansing Community College who uses a SPLOTbox as a means for students to share their Starscapes projects. She was interested in using categories to organize the responses by year, but did not want that to be an option on the sharing form that the students see.

I already had an admin option in all SPLOT themes to not use (hide) or use categories and tags on the form and the display of published items– it was pretty simple to add a new option to cover the way Suzanne was seeking to use them.

New theme option on tags and category settings shown for TRU Writer, the third one uses them to organize and display on items, but they are only editable from the admin side (e.g. for internal organization purposes)

This would mean assigning to categories and/or tags is only done by a admin after something is submitted. Yes, a rather specialized thing to have, but easy to include without changing any previous functionality.

Customize SPLOT Metadata Labels

For quite some time all SPLOTs have made use of the WordPress Customizer so site owners could change the labels and prompts for the forms where their visitors add content. This too was an idea that came from a user, I believe it was Lauren Heywood at Coventry University who asked because the hard coded ones I had in the first generation were not always understandable to a particular course. Making them editable allows a SPLOT owner to be very site specific as to what kinds of things were asked of on a form.

This is all find on the place where a form asks for a person to credit or how a license is described, but I had overlooked that on the templates where an item is output, that the labels were still hard coded.

Suzanne’s questions made me make this much flexible, as she was repurposing the attribution credit fields for the SPLOTbox for students to enter the name of the faculty member they worked with.

So all three SPLOTs now offers customizer options so an owner can change the labels for where content collected from the form is displayed- en example here for SPLOTbox:

This is pretty easy since it uses the same functions the Customizer uses to output the options (or default) on the form page.

Suzanne also expressed interest in a way to manage the order in which the form items are displayed and the way the information is published on an item. This one is a bit more complex, and might need a bigger can of polish. But it’s on my mind.

Shining Up Non-SPLOT Authored Posts

One example I looked at used the basic WordPress post (usually renamed as “Item” in a SPLOT, but still a humble post) to create ana bout page or maybe a sticky item as instructions for users. This is all fine, but the output template for a single items ends up posting extra information that comes from content created in a SPLOT form.

This just took a few extra checks to only output these elements if present as custom fields, and for the place where it enters the “name” entered on a form, if not present, uses the post author. Little bits of code do this like:

$wAuthor = ( get_post_meta( $post->ID, 'wAuthor', 1 )) ? get_post_meta( $post->ID, 'wAuthor', 1 ) : get_the_author() ;

These are thing maybe only the person with the shoe shine box might notice, but I do enjoy these small bits of spiffing up.

And my obsession with these SPLOT things continues, largely fueled when I hear from someone else putting them to use. Cue the music... The SPLOT Goes On…

A heavily re-edited parody of an ATCO 45rpm record, the featured image on a YouTube video of Sonny and Cher’s “And The Beat Goes On.”  Likely not 100% open license kosher. Shrug.

Featured Image: I remixed my own photo of a very special box in real life, a shoe shine box my Dad made as a kid in Newark, New Jersey. I still have it, along with the tins of old polish. It fit the metaphor! Classic Shoe Polish flickr photo by cogdogblog shared under a Creative Commons (BY) license

Older Post Newer Post