Creating a Shortcode for the Organize Series WordPress Plugin

Insert this code into your WordPress functions.php file (or custom_functions.php if you’re using Thesis like I am) to enable a quick way to display a series of articles created with the Organize Series plugin.

function get_thumb_series( $atts ) {
	extract( shortcode_atts( array(
		'ser_id' => false
	), $atts ) );
	if ('ser_id' == false){
		return false;
 	global $post, $orgseries;
	$series_post = array();
	$posts_in_series = array();
	$settings = $orgseries->settings;
	$ser = $atts['ser_id'];
	$result = '<div class="episode-list">';
		$series_post = get_objects_in_term($ser, 'series'); 
		$posts_in_series = get_series_order($series_post, 0, $ser, FALSE);
		foreach($posts_in_series as $seriespost) { 
				$result .= token_replace(stripslashes($settings['series_post_list_post_template']), 'other', $seriespost['id'], $ser_ID);
		$result .= '</div>';
		return $result;
add_shortcode( 'get-ts', 'get_thumb_series' );


On any post or page (and possibly anywhere else) where you want to list a particular series, enter the following shortcode:

[get-ts ser_id='n']

where n is the ID of the series you want to display (you can find this in the Manage Series admin page).

So, for instance, if you want to display a list of posts contained in a series with ID=10, you’d enter the following in the text of the post or page:

[get-ts ser_id='10']

Why and How did I do this

I’m using the wonderful Organize Series plugin on a site I’m working on to display hundreds of TV episodes together in a logical arrangement. As part of my CMS strategy, I needed a way to display the content of a series on a page that is not a part of the series.

Suppose you have all the episodes of “The Big Bang Theory” organized in a series so that you can jump from one to the next in a logical order and not be constrained by a blog’s chronological ordering system. If you want to create a page with additional info about the show, there’s no clear way to add the episode list to the page. This Shortcode will allow you to do just that.

The Organize Series plugin includes a file filled with useful functions (orgSeries-template-tags.php in the plugin’s folder). Figuring out how to put all that info to good use was a bit harder, since Organize Series now keeps all their support forums behind a pay-wall. The Internet Archive’s Wayback Machine solved that by letting me look at some older pages from back when the support forums where open.

Further help came from Aaron Jorbin’s post on WordPress Shortcodes – A how to by example.

The nice thing about this Shortcode is that you can edit the output to suit your needs. The reason I called the function get_thumb_series is that I originally wanted to generate a list of episodes with a thumbnail next to each one. I still haven’t done that, but there’s nothing keeping you from changing the function to return whatever it is you need. I’m currently using the default functions within orgSeries-template-tags.php (and the function itself is an abridged version of get_series_posts()), but will eventually add my own to return just the information I need about every episode (thumbnails, air dates, duration, etc).

I’ll add links to example pages once the site goes live. In the meantime, let me know if this article was helpful to you and feel free to post any fixes or updates.

  • great work! I wondered if someone would get a shortcode out before I did :)

  • Thanks Darren. I really like the plugin so far… This is the first
    shortcode I write – I plan to add a bit more to suit the website I’m working
    on (I’ll send you a private link) – I’ll share back whatever I come up with.

  • I’m glad someone wrote this!

    I have a question / request. Would it be possible to write a shortcode that would provide a link for the latest series published, and also one for the second latest series, or better yet, the previous series to the one users would be viewing?

    I’m trying to organise groups of posts across multiple categories into editions, or issues, published by a newspaper that works as a weekly news source. So I need to organise posts according to weekly issues, but also to provide links to previous issues.

    Would this be possible? Is there a mod to your shortcode that would work?

  • Hey Ian, check out the Organize Series Shortcodes addon that I released recently.  I think it will do what you want.

  • Man, what a great tutorial you put up here! I was able to modify it quite a bit for my needs, and I may do a write up about it in the near future, if so I’ll link back to you! Actually, I learned a lot more than just displaying stuff in OrgSeries, I learned about making shortcodes and understanding php, which I usually leave to others in the company. Great job!

  • I’m glad you liked it and could take something away from it. I’m planning on expanding this post with some additional features I’ve added to the shortcode as well as some work I’ve done with functions.php.