Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Version 1.2   Updated Thursday, February 19th, 2009 at 7:19pm

Expanding Text plugin for WordPress

This WordPress plugin allows you to create sections of text in your post or page which expand/collapse when clicked on. You simply wrap the special tags around your text, and set the ‘expand link’ (the link visitors click on to show the text). If your visitors do not have javascript enabled, the ‘expand link’ is not shown, and the text is displayed normally.

Download

  If you have found this page useful, please consider donating. Thanks!

Change Log

  • 02-19-09 Version 1.2 – Changed wrapper tags *must change existing links when updating!* Fixed validation errors, and issues switching between code and html view
  • 10-09-08 Version 1.1 – Now works properly when the exact same expanding text is used more than once on the page
  • 08-14-08 Version 1.0 – First release

Installing

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
  • Enable the plugin.
  • Optional: Add the CSS to your theme’s style sheet to make it look nice (see the customization section below).

Usage

To make your text expand/collapse, use the following format in your post or page:

Important: Make sure you add this using the html/code editor in WordPress, not the visual editor. In new versions of WordPress, just click the ‘html’ button above the edit box. If you use the visual editor it will not work, as the actual code you entered will be seen on the page, instead of being processed by the script.

Notice: If upgrading from version 1.1, make sure you change your existing code to match the examples below. The tags have been changed to cause less issues.

[DDET (expand link text)]
(Text to expand)
[/DDET]

Example:

[DDET Click to expand!]
Here is your text!
[/DDET]

You can add as many sections of expanding text as you like.

Demo

Here you can see the plugin in action:

Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text! Here is your text!

Customization

To style the expanding text boxes, you must add the .ddet_div class to your theme’s css file. Here is an example:

.ddet_div {
  margin: 8px 0 0 12px;
  padding: 8px;
  background: #F4F4F4;
  border: 1px solid #DDDDDD;
}

Pages: « 9 8 7 6 5 4 3 2 [1] Show All

  1. “it does not work, even in a newly installed Wordpress.

    “Fatal error: Call to undefined function: str_ireplace() in /www/htdocs/(myserverver)/blog/wp-content/plugins/dd-expanding-text.php on line 46?

    - I’m getting the same error. Any suggestions?

  2. I wonder, is there any way at all to retain the functionality of this plugin, and be able to put a link to another page or site in the (Click to expand) portion of the tag?

  3. 13
    Mike

    Great plugin!
    Is there any way to have “expand all” and “collapse all” links on a page that would expand/collapse all instances of text wrapped in the DDET tags?

  4. 12
    Fabricio

    Hi there!

    Very usefull plugin, but there is an annoying limitation: I can not use it to broke sentences. In other words: I’d like to use it just in the middle of a sentence and then the close link should be placed elsewhere, like in the end of the post.

  5. It works great on my computer, but on my other computer, which is basically identical aside from having SP2 of XP instead of SP3, the links don’t expand the text, instead they open new windows, and nothing pulls up.

    I checked js and it’s all working good, fully updated, and works on the rest of my site from that computer, just not DDET. Any ideas?

    This plugin also doesn’t work very well with AWP, causes all kinds of erratic behavior, though I worked around it just fine.

  6. jay: Just as a test, you might want to try using another theme. One of the default ones perhaps.

  7. Very nice plugin. Allow me to post new content even on days when I don’t feel like writing out a long or even slightly detailed post. Love it!

  8. exactly what I was looking for, many thanks!

  9. hi thanks for trying but that still didnt work. I am using wordpress 2.6 using the WP Remix 2 theme if that helps at all. It just doesnt seem to work on anything except safari, i dont understand.

  10. ok will give it a try when i get home, thanks and will let you know :)

  11. I have tested in IE and Firefox – a few different versions – without any problems.

    Do you have Javascript disabled?

    Val: That means you are using a version of PHP before 5.0, and the str_ireplace function does not exist. This has nothing to do with WordPress, but rather PHP. I just made a small modification to the file so it uses the standard str_replace function though. Try it again if you like.

  12. i just cant get this to work properly, it seems to work on safari but not IE or FF? Maybe im doing something wrong?

  13. This doesnt seem to work in firefox?

  14. it does not work, even in a newly installed Wordpress.

    “Fatal error: Call to undefined function: str_ireplace() in /www/htdocs/(myserverver)/blog/wp-content/plugins/dd-expanding-text.php on line 46″

  15. Wow…I love it! This is great! Now, I just need to find a use for it!

Pages: « 9 8 7 6 5 4 3 2 [1] Show All

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.