WP-ShowHide: Embed Text Within Your Posts With A Show/Hide Link

WP-ShowHide: Embed Text Within Your Posts With A Show/Hide LinkIf you’re an experienced WordPress user, you may have heard of Lester Chan (otherwise known as “gamerz”). Lester is the author of no less than 19 plugins, of which 4 feature on the WPMU Top 100 Plugins list. That’s more than the likes of Joost de Valk, Automattic, or anyone else for that matter.

I recently interviewed Lester for ManageWP, and so had the opportunity to take a closer look at all of his plugins. One that caught my attention in particular was WP-ShowHide. It is very simple, but what it does, it does well.

The idea for WP-ShowHide came from the way in which Engadget embeds press releases within posts (here’s an example). And whilst the plugin certainly can be used to present press releases in that manner, it can also be used to embed and show/hide any form of text.

Featured Plugin - WordPress Newsletter Plugin

Now there's no need to pay for a third party service to sign up, manage and send beautiful email newsletters to your subscriber base - this plugin has got the lot.
Find out more

How Does It Work?

Using WP-ShowHide couldn’t be any simpler – just wrap the text you want to embed in [showhide][/showhide] tags, and readers will see the following:

WP-ShowHide

If a visitor clicks on the link, the text appears seamlessly, and the link text changes accordingly:

WP-ShowHide

As you can see, I am using the trusty T’Lipsum Generator for my dummy text (I’ll take any excuse to plug it).

By default, the shortcode assumes that you are embedding a press release. However, you can define a few different variables from within the shortcode to control settings:

  • type – if you want to include more than one block of embedded text within a post, you need to name each one using this variable.
  • more_text – use this variable to define the text that is displayed when the embedded content is hidden. Include “%s” to display a word count.
  • less_text – conversely, use this variable to define the text that is displayed when the embedded content is displayed.
  • hidden – define as yes/no to determine whether the embedded content is displayed or hidden (by default, it is hidden).

Here’s an example using all of the above variables:

1
[showhide type="podcast" more_text="Show Podcast Transcript (%s words)" less_text="Hide Podcast Transcript" hidden="yes"](Podcast Transcript)[/showhide]

And here is the end result:

WP-ShowHide

WP-ShowHide

That’s it! There are multiple potential applications for WP-ShowHide – how will you use it?

Download WP-ShowHide here.

Creative Commons image courtesy of Ernst Vikne

Comments (4)

  1. Thanks Tom for using the T’Lipsum Generator for Yorkshire folks…. as an exiled Yorkshireman I really appreciate it (and yes, i do understand it, well if it made sense I would) … a taste of home :-)

    Over to the review. I’ve been using numerous plugins from gamerz as long as I’ve been using WordPress I think. They always do the job they advertise perfectly with no frills, just great, down to earth stuff. I would recommend any of them.

Participate