I have created a new plugin, WP-ShowHide. It is a simple plugin (83 lines of codes including comments) with no configuration screen needed.
This new plugin came about when Hisham tweeted me about whether there is a “Show/Hide Press Release” WordPress plugin like what Engadget does when posting a Press Release.
I can’t seem to find it and decided to code one myself using WordPress ShortCode API. I made the plugin more generic rather than focusing on Press Releases, so you can have multiple Show/Hide content within a post.
I tested it on WordPress 3.1.1 but technically it should work with any version higher than WordPress 2.5 because ShortCode was introduced in WordPress 2.5.
WP-ShowHide Description
Allows you to embed content within your blog post via WordPress ShortCode API and toggling the visibility of the cotent via a link. By default the content is hidden and user will have to click on the “Show Content” link to toggle it. Similar to what Engadget is doing for their press releases.
Example usage:
[ showhide type="pressrelease" ]Press Release goes in here.[ /showhide ]
(Remove the spaces before and after the square brackets [].)
Download: WP-ShowHide 1.00
Documentation: WP-ShowHide
Demostration/Example Usage
Remove the spaces before and after the square brackets [].
Tag: [ showhide ][ /showhide ]
Tag: [ showhide type="links" more_text="Show Links (%s More Words)" less_text="Hide Links (%s More Words)" ][ /showhide ]
Tag: [ showhide type="visibility" hidden="no" more_text="Show Visibility Content (%s More Words)" less_text="Hide Visibility Content (%s More Words)" ][ /showhide ]
The visibility of this content is set to display by default instead of hidden.
thank you for your help Lester. I think this could be one of the more popular plugins soon! hehe 😉
This is the plugin I have been searching for.
Thanks bro for this awesome plugin 😛
You might put the code directly into php? When the post was created, the code would have his job.
Thanks
Great job! It would be useful for many uses.
My only problem seems to be that, if I style the trigger text, when the extra text is shown the trigger text shows the HTML markup. For example:
What We Do
when clicked appears something like
What We Do
What We Do
Sorry, I thought it would ignore the “strong” tags in the markup example, and I don’t see any way to delete this comment. I hope you understand what I’m trying to say. Am I doing something wrong, or is there a workaround for this? Thanks in advance for any advice.
Sorry I don’t get what you mean, do you have any screenshot for me to visualize? You can drop me an email, lesterchan AT gmail
Many thanks for the plugin! I have just one problem. Although I defined “more_text” there is still displaying “Show Press Release (..)”. Less text works normally.
Can you tell me the easiest way to remove the “more words” part?
For example, don’t show:
Show Press Release (1,011 More Words)
just show:
Show Press Release
great plug-in Lester. thanks!
Finally, I found this… Just installed the plugin and well, it’s awesome! Thanks for that… Just a question though, is it possible to change the “Show/Hide Press Release” text so it would appear graphical like that of Engadget? Or at least make it bigger to match with the theme?
Regards,
-Bert
You can style it via css. class name is links-link
Hi Lester, Thanks for a great plug-in. I would like to use it to show / hide an image, more specifically, a map. The website is for a recreation park and there are 2 map types. I am using the plugin to show / hide the different maps. Therefore, I don’t it to say ‘Press Release’. I would like the link to say ‘Show Trail Map 1’ and ‘Show Trail Map 2’. Thanks!
Can this be used to show/hide videos?