WordPress Plugin Review: Expire Tags

WordPress Plugin Review: Expire Tags

I first heard about the WordPress plugin Expire Tags on Twitter and the name intrigued me.  This plugin lets you assign a date to a post tag to expire that tag.  The post does not disappear, but the tag is no longer associated with the post.  In what scenario would you use this?

Display Recent News

Let’s say I want to have a page that just displays the most recent security issues for WordPress.  As an issue comes up I can give it a tag starting with “SI” and ending with the date “21042015”.  I also assign the post to the categories “WordPress” and “Security”.  This issue is an important one, so I want it to show up on the security issues page for a month.  I set the tag “SI21042015” to expire after 30 days.   The issue won’t show up on the security page after 30 days, but it will still appear in my blog (which shows all of my posts).

How would I show which posts to display on the security page if I’m using a separate tag for each day’s posts?  The key is in the “SI”.  I write a simple query that only looks for tags that start with “SI” and display those.

Display Upcoming Events

I have a client that is a youth fastpitch organization with a page that displays upcoming tournaments and the teams signed up for each tournament.  Right now that page is a static Page, not a series of Posts, but that means when a tournament is over it is deleted and team members can’t look back and see who played in past tournaments.  I could advise the client to create a Post for each tournament and then I would recode the Page to show the Posts.  If we assign a unique tag to each tournament we can have the listing expire from the upcoming tournament page, adding a Page that displays past tournaments – maybe even with scores and other information.

How Expire Tags Works

Install the plugin as usual and activate it.  To add an expiration date to a tag it must exist, so first go to Posts->Tags and add your tag.  Then go to Settings->Expire Tags and use the calendar icon to add the expiration date.  Make sure you scroll to the bottom of the list and hit Save.

My Thoughts

I like the idea of this plugin, but I think the execution is a little clumsy.  This is author Raul Martinez’ first plugin, however, and the first iteration.  And it works as advertised!  There are a few suggestions I’d like to make:

Description

Most important, I think a better description of the plugin and what it does is needed.  The current description is concise, but I found it confusing:

Expire tag allow to expire your tag on a date basis. The tag will not be associated to your content but the tag will not be removed.

I’d suggest something more along the lines of:

Expire tags allows you to add a date to a tag to expire it.  When the date is reached the tag is no longer associated with the post, but the tag is not removed and the post is not deleted. This could be used to display a custom query by tag of important issues or upcoming events.

Adding Dates to Tags

This is a little nit-picky, but the list of tags gets really long really quick.  The current method of assigning a date to a tag consists of listing all of the tags with an input box and a datepicker.  A cleaner scenario would be to use AJAX and an “Add Expiring Tag” button.  Click on the button to add a new line with a  select box listing all of the tags, the input box and datepicker appears.  To add more expiration date, the user clicks on the “Add Expiring Tag” again.  I feel this is a little more elegant, but I’m sure the author has considered it for a future iterations of this plugin.

Fleshing out the Documentation

As part of the documentation I’d also suggest providing some sample code that shows how to display the tags.  One or two examples is fine.  For example, to achieve the result I described above I might do something like this (this isn’t tested, mind you):

$the_query = new WP_Query( 'category_name=security,wordpress' );
if ( $the_query->have_posts() ) : ?>

	<!-- pagination here -->

	<!-- the loop -->
	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
         <?php if(strstri(the_tags(),'SI')){  ?>
		<h2><?php the_title(); ?></h2>
               <!-- Display post content here...-->
         <?php endif ?>
	<?php endwhile; ?>
	<!-- end of the loop -->

	<!-- pagination here -->

	<?php wp_reset_postdata(); ?>

<?php else : ?>
	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

This just does a query that returns posts that are in both of the categories “WordPress” and “Security” and only displays posts with a tag containing “SI”.  If I wanted to think a little harder, a regex statement would be better for the filtering.

Conclusion

A nice plugin that solves a niche problem.  Hopefully we’ll see more from this author.

Follow me

Trackbacks/Pingbacks

  1. The #1 Way to Learn to Code - Beyond Paper - […] plugin.  A couple of weeks ago I had an idea for a plugin that I cared about.  Inspired by…

Submit a Comment