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: « 1513 12 11 10 9 [8] 7 6 5 4 31 » Show All

  1. Thanks! Works perfectly ;)

  2. 119
    Thomas

    Is it possible to change the color of the expand link text itself? I didn’t succed….
    Cheers,

    Thomas

  3. 118
    tony

    Hi, thanks for the great plugin, working fine, but I have a BIG problem. I have a site with many posts, more than 150 and i want to know if is possible to write a code inside the single.php file for all the posts and not trying one by one.
    Thank you!

  4. Thanks for yor content. I’m looking for how to expend my text. Now, it really can help me. Thanks.

  5. for who cant download the plugin

    Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
    Enable the plugin.

  6. 115
    Raz

    I do not want the text-box in the expanded state.
    More importantly, how 2 display a -
    “+” 4 the collapsed state &
    “-” 4 the expanded state.

    In fact, I want my text 2 look like this –

    + Collapsible text (in the collapsed state)

    - Collapsible text
    ——————
    —————-
    —————–
    - Close

  7. 114
    Jacky

    Why it can not be download?

  8. 113
    Paul

    Same as below…how to download this plugin?

  9. Sorry to be an idiot but I don’t know how to download this plugin. The ‘latest release’ link under Download just comes up as text and I can’t download or save in order to do as instructed and save as php.
    Thanks, Phillippa

  10. I, too, want there to be a “hide” when the div is expanded, but I can’t follow Heman’s code, anyone got a clearer version or line numbers to guide me on what to edit?

    thanks!

  11. Thanks a lot. That is really what we want.

    We make a bit change. We move the expanding tag to the end of text and change it something like ‘… Hide’ when people click the original tag.

    /* $new_string = ‘‘;
    $new_string .= $sdesc . ‘
    ‘ . “\n”;
    */ $new_string = ”;
    $new_string .= ‘expand(document.getElementById(\’ddet’ . $rnum . ‘\’));’;
    $new_string .= ‘expand(document.getElementById(\’ddetlink’ . $rnum . ‘\’))’;

    $sdata = preg_replace(‘`^`sim’, ”, $sdata);

    $content = ddet_str_replace_once($sstring, $new_string . $sdata . ” . ‘‘ . $sdesc . ‘‘ . “\n”, $content);

    Heman

  12. hi, i’m trying to download the plugin which is a text file. i renamed it as .php like it says but something about it doesnt work. could someone tell me if im doing something wrong or email me the actually plugin compatilble file to buty_2892@yahoo.com, i would appreciate it.

  13. Great plugin but one problem – here is an idea!

    If anyone has spacing problem, see how I resolved it…
    could not fix it in the code but if you make Linked Text 1 as a title then it looks ok I guess. Hope this helps.
    How I did IT!
    http://www.golfputtingonline.com/qa/

    Linked Text 1

    Linked Text 2
    Linked Text 3
    Linked Text 4
    Linked Text 5

    Leanne

  14. BRILLIANT.
    Works fantastically well.
    Have used it for all our clinical questions and medical trivia…thanks so much for this brilliant code
    Mike

  15. I installed the plugin, but when I activate, it comes up with this error message.

    Parse error: syntax error, unexpected T_FUNCTION in /home/www/Samuelpa/samuelpanda.co.uk/wp-content/plugins/dd-expanding-text.php on line 18

    Can somebody let me know if they have a solution.

Pages: « 1513 12 11 10 9 [8] 7 6 5 4 31 » 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.