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;
}
  1. 135
    D.H.

    Opps, after step 3, you must UPLOAD the php file into “expand-text” directory, if it wasn’t obvious. Der.

  2. This does work perfectly in Wordpress 3.0.1, here’s how to install the plugin:

    1) Save .txt plugin as expand-text.php – Rename the file if necessary
    2) Start up your FTP, go to /wp-content/wp-plugins/
    3) Create a directory called “expand-text” (w/o quotes)
    4) Go to WP-ADMIN web page, click on Plugins
    5) You will see the Plugin as “Expanded Text” but it will be list as Deactivated
    6) Activate plugin
    7) Use as instructed

  3. This plugin seems to stop image verification working on the Form Mailer plugin! When expanding text is activated, the image for verification on Form Mailer pages just shows an image place-holder, not the image!?

  4. doesn’t work for me. Check out my website at http://www.govpoliceimpouncars.com for deals on new cars

  5. 131
    Gopalan

    <?php get_header();?>

    I have a problem in tag’s in my website.

  6. I have included a website link to the test site I am using your plugin for. Any way I can have a + and – image in the corner as a visual. At the moment I have the down arrow but would like to make it an up arrow on expand.

    thanks

  7. 129
    Karan Singhal

    How to you make the link go under the content when it appears? When the content appears when you click the link, how do you make it go above the link?

  8. 128
    Rosana

    I works just fine!!! Thanks a LOT!!!!!!

  9. 127
    Chippa

    seems to work for me in 3.0
    one thing i have noticed is that it doesnt render properly in archives. you can see bits of javascript and all the text in the summary

  10. 126
    Nick

    Please, Please make this work on 3.0

  11. 125
    scott

    this doesn’t seem to work with Wordpress 3.0??

  12. 124
    Rajmohan

    Hello,

    Does the code between DDET and /DDET is crowled by Search Engines or not? I am not sure if any hyperlinks and text between the expanding text plugin will be available to search engines to index or they will be left by engines for being within javascript.

    Can some one clarify this to me?

  13. 123
    Leigh

    RE: Post 108 (Leanne) Good work around. But, would still like to know what’s the problem as I have it as well. Great Plug-In thought!

  14. I´m using your plugin to make an expandable list. Works fantastically well.
    Thanks

  15. Great plugin! I´m using it to make an expandable list. I have struggled to expend my articles in pho code. Now, I can solve my problem using your plugin. Thanks.

  16. Thanks! Works perfectly ;)

  17. 119
    Thomas

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

    Thomas

  18. 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!

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

  20. 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.

  21. 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

  22. 114
    Jacky

    Why it can not be download?

  23. 113
    Paul

    Same as below…how to download this plugin?

  24. 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

  25. 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!

  26. 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

  27. 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.

  28. 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

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

  30. 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.

  31. Hi there! cool plugin which can be very useful in some cases. just a question though. it has been asked before but has not been answered as yet i believe. is it possible to choose the heading size and font (for example H1, H2, H3…) for the title that commands the expanding text? it seems the plugin does not work when you change it. I’d like the headings to look bigger than the expandable text on http://www.worldsbestbeaches.net/australia/bondi-beach-australia.html
    thanks for the great plugin and for the support!
    brice

  32. Great plugin and does the job but for me it leaves a lot of space between the first and second link.
    Example:

    Linked Text 1

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

    I can see someone already asked this question but it was not answered.

    Can anyone help?
    Leanne

  33. 103
    mali

    Can I add this Plugin into the template? Because I want to use it inside the template code.. not actually in the post or page? is it possible?

  34. I would really love to use this plugin, but as it is now I don’t know how to install it. It doesn’t even show up in Wordpress’s plugin installer. So please update the plugin with a zip that can b e used to install in Wordpress.

  35. 101
    Matt

    Hmm. This script isn’t very search friendly.
    The built in WP search returns a lot of the javascript too.

    expand(document.getElementById(‘ddet1162979334?));expand(document.getElementById(‘ddetlink1162979334?))

    Appears between the button text and the expand text on each search result. Ugly.
    Can we get a fix? :)

  36. 100
    Max

    So, I tried installing this (and I believe I installed it correctly), but it doesnt work. Whenever I implement the DDET tags, all that happens is the text in the tags goes blank

  37. Any resolution on this?

    When I have multiple expanding text blocks, one after the other, the first one adds a large margin before the second.

    Example:

    Linked Text 1

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

    Live – http://trusupremekillaz.com/tsktesting/?p=634

  38. Hi, anyone know if the text inside the hidden content is visible to Googlebot when the page is indexed? Thanks

  39. nice script. my only complaint is that it has some weird spacing issues (putting space or break where there appears to be none in the html). also when i save it, sometimes the code is messed up.

  40. thank’s for the info

  41. Great plugin! Thank you.

  42. 94
    melux

    Hi,

    first of all, really nice work !
    I just have a small question : does someone know how I could make something like

    
    [DDET an image that will be just for one post ] my text [/DDET]
    

    Just to explain : I want to only have an image in my post, that will be the link of the DDET code. I can’t put my image in the php code cause I want one different image by post. Am I clear ?

    Thanks !

  43. 93
    xavier

    This is a great plugin, however i can’t have it work with a form plugin called ‘mm forms’.

    When mm forms is deactivated ddet works fine, when mm forms is activated ddet shows as if javascript was disabled.

    Any idea why so, and above all how to fix that?

    Thanks

  44. Great plugin!
    I´m using it to make an expandable list. Is there a way to automatically collapse an open text when a new element is expanded, as to ensure there is never moore than one element expanded?

  45. 91
    Thomas

    Hmm. If I try to use this in conjunction with a document’s H1/etc formatting, it tends to not work:

    
    <h3>[DDET Chiropractic Addresses All Three Types of People]</h3>
    First, chiropractic is the art, science and philosophy of adjusting the vertebrae of the spinal column in order to restore and maintain normal nerve flow, which in turn, assists the body with normal health and healing.[/DDET]
    

    Any suggestions for this? Thank you in advance for your help.

  46. Nevermind my last… It’s working now…
    Thanx.

  47. The plugin does not have a valid header.

    I got that error when activating the plugin. I’m using WordPress 2.8.
    How can i solve this? thanx…

  48. 88
    Brian

    I really like your plugin. I like how you can use style sheet customizations. Here is my issue I would like to have multiple links customized but i can’t use the div id number because it changes every refresh. Is there a way to do this?

  49. Hi. Just a quick one. How can I add an image, when at default, maybe displays a “+” sign to display the content and when clicked/ toggled, displays a “-” sign to hide content. How can I go about doing that? Anyone? Much appreciated! Cheers!

    Lea
    Malaysia

  50. I was looking for this very function in wordpress. Very useful plugin indeed! How to add the sliding effect to this? Could you please add that too?

  51. As Usual from Dagon Design, Simple But Sweet,

    Thanks Guys.

  52. Perfect, worked like a charm. Thank you.

  53. Thanks so much for this plugin. I only have one question. Where in the CSS style sheet does the customization code go?

    Thanks again!

  54. 82
    nguJ

    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

  55. This plugin has been tested, and works with the latest release (2.8)

    Rolando: Adding those extra lines in the javascript may prevent it from working properly. I would re-install the plugin.

    I am looking into other options for the script, but making the javascript work as it does now was tricky enough ;)

  56. thanks! this version sorted out a bug in the last one which kept making me re-enter the code everytime i made a change to the post, the new [DDET] tag seems to have fixed it.

  57. Well I tried again on another website I own but with a wordpress 2.6.1 version, and the problem is still the same…

  58. Well I don’t know why there’s the same id on both DDET and yours has 2 different id… I’m usig Wordpress 2.8, maybe that’s why it’s not working?

  59. Here’s the screenshot of the code
    http://www.zimagez.com/zimage/ddet.php

  60. Hi Rolando,

    I haven’t deleted those lines. Do I have to?

    [quote]
    L47: mt_srand((double)microtime()*1000000);
    L48: $rnum = mt_rand();
    [/quote]

  61. 75
    Rolando

    FABIEN: I paste the same

    
    [DDET Price in Dollars ]
    250 dollars
    [/DDET]
    
    [DDET Prices in Euro]
    price in Euros
    [/DDET]
    

    is working fine in my website, I’m check in ff3.5, and ie8 and safari4. and looks fine in all .

    the only weird stuff that I saw in ur site (view source mode) was that the id is the same in both links..

    
    <p><a style="display:none;" id="ddetlink1711057188" href="javascript:expand(document.getElementById('ddet1711057188'))">Price in Dollars </a>
    <div class="ddet_div" id="ddet1711057188" onclick="expand(document.getElementById('ddet1711057188'))"><script language="JavaScript" type="text/javascript">expand(document.getElementById('ddet1711057188'));expand(document.getElementById('ddetlink1711057188'))</script>
    250 dollars<br />
    </div></p>
    <p><a style="display:none;" id="ddetlink1711057188" href="javascript:expand(document.getElementById('ddet1711057188'))">Prices in Euro</a>
    <div class="ddet_div" id="ddet1711057188" onclick="expand(document.getElementById('ddet1711057188'))"><script language="JavaScript" type="text/javascript">expand(document.getElementById('ddet1711057188'));expand(document.getElementById('ddetlink1711057188'))</script>
    
    price in Euros<br />
    </div></p>
    
    did u comment or delete this lines in ur copy of the plugin?
    <code>
    L47:                mt_srand((double)microtime()*1000000);
    L48                $rnum = mt_rand();
    

    in my source looks like this: (yes I add some “\n” in the plugin just to make it look pretty)

    
    
    <p><a style="display:none;" id="ddetlink575082508" href="javascript:expand(document.getElementById('ddet575082508'))">Price in Dollars </a>
    <div class="ddet_div" id="ddet575082508" onclick="expand(document.getElementById('ddet575082508'))">
    <script language="JavaScript" type="text/javascript">expand(document.getElementById('ddet575082508'));expand(document.getElementById('ddetlink575082508'))</script>
    
    250 dollars<br />
    </div></p>
    <p><a style="display:none;" id="ddetlink1711943988" href="javascript:expand(document.getElementById('ddet1711943988'))">Prices in Euro</a>
    <div class="ddet_div" id="ddet1711943988" onclick="expand(document.getElementById('ddet1711943988'))">
    <script language="JavaScript" type="text/javascript">expand(document.getElementById('ddet1711943988'));expand(document.getElementById('ddetlink1711943988'))</script>
    
    
    

  62. 74
    eheuristic

    Hi
    This really nice.
    now I just search this is only one site
    because this site is really cool….

  63. Thank you Rolando. unfortunately, it’s still not working.
    See what happens : http://www.isi-asia.net/expand.html
    password: test

  64. 72
    Rolando

    thank you for this. keep it simple. works awesome. I just add the option to click and expand again in the div. ..
    before:

    
    Line 53:
    $new_string .= '<div class="ddet_div" id="ddet' . $rnum . '">';
    Now
    Line 53:
    $new_string .= '<div class="ddet_div" id="ddet' . $rnum . '" onclick="expand(document.getElementById(\'ddet' . $rnum . '\'))">';
    

    it works for me. ;)

  65. 71
    Rolando

    thank you for this. keep it simple. works awesome. I just add the option to click and expand again in the div. ..
    before:
    Line 53:
    $new_string .= ”;
    Now
    Line 53:
    $new_string .= ”;

    it works for me. ;)

  66. Hi again, you said : “Now works properly when the exact same expanding text is used more than once on the page” with the 1.1 version… I have only the 1.2 version, ad it’s not working. I’ve never tested the 1.1 version… Is ther any special tags to write to get multiple expandable link text???

  67. Hi. It’s working great. But I would like to ad more than 1 click to expand.

    When I ad the only one tag, it’s working, but when I want to ad more expanded link, the function is not working anymore:

    [DDET Price in Dollars ]
    250 dollars
    [/DDET]

    [DDET Prices in Euro]
    price in Euros
    [/DDET]

    What can I do to make it works?

  68. Nice plug-in. If we may add two questions: How could we make the (click to expand) text toggle to (click to close) text when expanded? Secondly, how could we modify the script so that the post displays fully expanded when viewed on a individual post page (as opposed to the index page) ? Thanks!

  69. 67
    Marco

    Hi, I’have a problem: probably I’m stupid but I really don’t understand how it works..
    in html mode I put:

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

    but the only thing that is displayed is “here is you text!”, there is no link to expand or collapse.
    If I put the code in template (footer or header..) it works.
    I’m not a wordpress guru and I’m going crazy.. please..

  70. Really good function, but is it possible to have as the Lightbox 2 function for opening and closing. And also to expand and collapse… This doesn’t work today.

    Thanks!

    Fredric

  71. Can the plugin be used to open with expanded text and then reduced when clicked?

  72. 64
    Andrea

    Hello,
    Thanks for your work on this.

    It is possible to include this in a template, so multiple posts show up as the title, and then the user can show/hide each post’s content?

  73. Hi, I’m having a strange behaviour with this plugin.
    I’m using WPMU and users are registered to the main blog able to post as contributor. As soon as I activate the plugin users who try to post a new post receive an error which says “there was an error, try again later”

  74. How can I give the link a different property/look? I am not able to give the expanding link a differnet look than the one used in my theme.
    Thanhks!
    Gabriele

  75. Is it possible to use this in the sidebar?

  76. Is there a way to make it so the link to make the text expand doesn’t show in RSS feeds, but the hidden text itself does? Otherwise, an awesome plugin, thank you.

  77. Version 1.2 Released

    The tags to use this plugin have been updated to ensure html validity. This means that if you upgrade from 1.1, you must change any existing tags for this plugin to work. Brackets are now used instead of greater than/less than signs.

    This should also fix the issue when switching between code and html views, although you should still use the code view to enter the tags.

    This version has been tested in the latest version of WordPress (2.7.1)

    Enjoy!

  78. Will there be a version for Wordpress 2.7?

  79. Thanks for a great plugin! Just what I was looking for. However, I have a problem with Firefox and Camino (based on Firefox). In those browsers, the page is distorted when using this plugin. The “hidden” text is shown and my menu is “destroyed” so that the page is unusable. The plugin works fine in Internet Explorer and Safari with the same page.

    I read that you’ve tried it in Firefox, but have you tried it in the newest version? I guess it has something to do with how Firefox handles JavaScript. Any ideas? A solution to this would be great! Thanks!

  80. One more issue:

    When I have multiple expanding text blocks, one after the other, the first one adds a large margin before the second. This behavior persists after changing the order, playing with spacing, carriage returns, etc.

    Example:

    Linked Text 1

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

  81. I was looking for a simple plugin that would enable expand/collapse text blocks with the simple use of quicktags in posts, but this plugin is a bit limiting.

    Requests:
    1. Because the linked text is inside the markup tag, it isn’t clear how to add styling to the linked text. Plugin ought to be compatible with standard text markup, possibly by moving linked text out of the brackets and into it’s own tag?
    2. Would be great to have an admin screen for setting the text (+/-), images, and/or styling for the linked text and how they change upon expand/collapse.

  82. 54
    Copernicus

    Hi there,

    First off, to Dagon Design, thanks for the great plugin!

    Second, to those experiencing the “code stripping” issue…

    I’ve been working with this plugin and have been frustrated by the WYSIWYG editor stripping out the required DDET tags.

    So, I edited the plugin file itself and resolved this issue by changing the normal tag brackets (the “greater than” and “less than” symbols) to be “[" and "]” in the following manner:

    Line 27:
    I changed $stag = '<DDET '; to read
    $stag = '[DDET ';

    Line 28:
    I changed $etag = '</DDET>'; to read
    $etag = '[/DDET]';

    Line 36:
    I changed $ds = stripos($content, '>', $s) + 1;
    to read
    $ds = stripos($content, ']', $s) + 1;

    In case any of the above text & code got messed up in this comment submission, I’ve pasted a modified version of the code at
    http://pastebin.com/f23bbf348 (NOTE: I made the version 1.1b to differentiate from the v1.1 code)

    Good luck everyone!

  83. In fact, now that I think about it, maybe the text to be displayed in the tag could be moved to the Settings page in the admin screens?

    Text to include: ______________
    Then tie that into the $sdesc in the plugin …

    Hmmm

  84. Try this again …

    BTW, to include an image, or to make all of your links say the same thing, edit the plugin.

    Look for this line:
    $new_string .= $sdesc . '</a>' . "\n";
    and add your text or image link before the </a>. But keep the single quotes ‘{your text here}</a>‘
    Then you’ll need to leave a space in the ddet tag: <ddet >
    There you go!

  85. The answer to the disappearing tag is really quite simple:
    Don’t use the visual editor. Nyuk nyuk nyuk.

    It’s like going into the doctor and saying, “Hey doc, it hurts when I do THIS.”
    The doctor will tell you, “Then don’t do THAT.”

    What I’m looking for is a way to change an image depending on whether the expanded text is being displayed or it is hidden.

    I have the images loaded already, but I can’t figure out where the check state is for the displayed text. I’m no js whiz (in case you couldn’t tell).

    BTW, to include an image, or to make all of your links say the same thing, edit the plugin.

    Look for this line:
    $new_string .= $sdesc . ‘‘ . “\n”;
    and add your text or image link before the . But keep the single quotes ‘{your text here}‘
    Then you’ll need to leave a space in the ddet tag:
    There you go!

  86. 50
    JAY

    is it possible to expanding the text and as well opening a website when clicking on it?

    thanks

  87. 49
    JAY

    Is it possible if someone click on it and it will show the text and also in the same time, open a website?

    please tell me how. i tried like

    Here is your text!

    above code is not working. anyone have any idea? I really need this help.

    thanks

  88. 48
    Casey

    Will you be changing this plugin to use shortcodes? (like mentioned in a previous comment above)… I don’t use visual mode but some authors do…

    PS. Would love to see you develop a newletter type plugin. There’s only one (really) out there and it is not supported by its author, even though it is a commercial plugin. I bet you could do a bang up job! (I’ll volunteer to beta test for you!)

  89. Nice to find out this plugin i would like to ask if we can use in visual editor too its disappers but
    really thanks for this even..

  90. Hi, This will be a wonderful plugin if it can get up and running. A few people have also had the problem of the code disappearing between visual and html mode. Is there a solution to this?

  91. Love this plugin but unfortunately can’t use it because the code disappears when switching between code and visual views in wordpress write screen…

  92. 44
    Angela

    I’d like to echo the concern that the code snippets disappear when the Visual tab is clicked. If the Visual tab is used on other pages, and you click to a page containing the expanding text, the Visual tab is selected by default and immediately all of the code disappears. A lot of other plugins use [] that aren’t deleted by the Visual editor. Perhaps there is a different way to call out the code (using [] for example), so that the Visual Editor doesn’t delete it, since the only way to prevent this from happening is to completely disable the Visual editor for the entire site.

  93. I love this plugin. You can do more. Create a beautiful background with a image to the expanded text. Or change the color of the h2 tag on your expanded text. Also you can give a h2 to the Click to expand text. A complete example with all the css changes and post is below:

    <DDET Click to expand!
    Here are some links to some of Freeware website resources
    More Freeware Download
    You can Customize the h2 tag to your “Click to expand text” and also add a h2 tag to your Heading on the exapanded text. For that you need to add

    a little text to your style sheet like given below
    .ddet_div {
    margin: 8px 0 0 12px;
    padding: 8px;
    background: #F4F4F4;
    border: 1px solid #DDDDDD;
    background-image: url(images/bg-blue-dot.gif);
    background-position: center 100%;
    background-color:#F4F4F4;

    }

    .ddet_div h2{
    color: White;
    }

    You can change the background image file or path to your own and also change the h2 font color inside the expanded text by editing the color: white tag

    Niket Kale
    http://www.trustMeher.net

  94. 42
    Willow

    PS should have said, thanks! I love this plug in!

  95. 41
    Willow

    Does this plugin not work on Wp 2.6.5? I have 2 blogs on the same server (different subdomains) using the same theme, and the only difference is that one is on WP 2.6.3 and the other on 2.6.5. Expanding text doesn’t work on the latter. Is it just me?

  96. 40
    Axeile

    Hi there, is there a way to change the window status message on mouseover? I tried adding onMouseover=”window.status=’click me’;return true;” into the php under $new_string but it returns a fatal error. I’ve also tried adding the onmouseover directly into the post but it didn’t work either. Currently javascript:expand(document.getElementByID(‘blahblah’)) appears in the status bar upon mouseover on the “click to expand” link.

  97. Love it, but please please answer the question that’s been posted twice: how to avoid loosing the tags, including ones own text, when you swap between html and visual modes. Can we hack the visual editor?! I don’t mind adding the tags in html, but would like to still be able to edit the page in visual mode. Thanks;)

  98. Do you think this would work well built into a theme?

    Cheers!

  99. Allow me to rephrase…

    
    <ddet &#11024; Expand &#9585; Collapse &#11023;>
    </ddet>
    

    <ddet ⬐ Expand ╱ Collapse ⬏>
    <╱ddet>

  100. I love this! I have been wondering about this for some time. And I am hooked, baby!

    Now, if we could only use little buttons instead of text ….

    
    &lt;ddet &#11024; Expand &#9585; Collapse &#11023;&gt;
    &lt;&#9585;ddet&gt;
    

  101. 35
    Pete Lingo

    This is almost a superb plugin. I’m using it on WP2.6.2 and it works fine, except for a small problem. In the Write Post screen, if you switch from HTML mode to Visual Mode to check the content and then switch back, the snippets have all disappeared. Infuriating. :-(

  102. 34
    Mark

    I would also like to insert this code into a php template file to show/hide comments. Is there a way that this can be done with your plugin?

  103. Hmm, first I was more than happy to find that plugin — but after running W3C Markup Validation I changed to “I should wait until it is 100% valid” state. Maybe you should have a look at the validation errors and try to fix them. I would be very sorry not to use your very useful plugin.

  104. Pierre: To use this plugin, you just add that text directly into your post or page (make sure you are using the code, not visual, editor in WordPress) – not the template files.

  105. Hello. Very nice plugin.
    I’m trying to put it directly in a template, for showing the excerpt of the post in collapsed mode, and the whole content in plain mode.
    But the code above seems not to be recognized :

    
    <?php the_excerpt(); ?>
    	<DDET Click to expand!>
    <?php the_content(); ?>
    </DDET>
    

    Got an idea ? Thanks

  106. For the question B) what I need a beginner’s tip on is how to set the style selector in my style sheet.
    I’d like eg the h2 tag to appear so and so when inside the .ddet_div – as you’ve described for styling.
    My guess would be something like

    .ddet_div h2{
    	color: #00FF00;
    }

    Thanks – believe this could be useful for others too :o )

  107. Hi
    Thanks for making this plugin – for a simple, nice functionality.
    I A) wonder how it is best to format the eg “Click to expand!” text, and B) also if its possible to include images here – somewhat like down left here.
    I’ve tried and (strangly enough) this works:

    <h2><DDET Click to expand!</h2>
    Here is your text!
    </DDET>

    Note the missing bracket after “expand!”.
    For the image/ other styling, I guess it can all be done using css, right?
    Thanks,
    Kjetil

  108. Nice plugin, and i have the need for for sure.

    But, it is only working to a point.

    Use html editor, and put in following :

    <DDET Click to expand!>
    Here is your text!
    </DDET>

    Press save, the page works like it should.
    But after it is saved, and looking at the backend of the page, the code looks like this :

    <ddet>
    Text to expand
    </ddet>

    And the script is not working anymore after i save it again (ie after editing the page)

    As you can see, the capital code letters are no longer capitals and the “link” text has dissapeared.

    How come? Because it is very irritating repairing everything before you save again after editing the page

  109. Hey now this seems like a pretty cool plugin. Definately something I could use. Thanks.

  110. Version 1.1 has been released. If fixes a bug in which multiple groups of expanding text did not work if you used the exact same text in each block.

  111. Thanks, that’s exactly what I need. Will be implementing it soon. Keep it up!

  112. 24
    eivind

    Well, it is a very interesting function. Neat and easy to use.
    But unfortunately not quite 100% working. When having used it in several posts the first post works fine, the second (with pictures) includes the pictures inside the tag, although I did NOT do it myself! The third post works somewhat ok, but shows 5 words from the text that WAS put inside the tags. I use WP 2.6.2.
    When will this be fixed?

  113. I am currently trying to figure out why some people are not able to use multiple sections of expanding text.

    Patrick: Yes, as the text is shown normally in the html.

  114. Great plugin. It works so smoothly.
    1 question though. Will Google treat text within the collapsible section the same as it normally would without the plugin?

  115. Is there a way to insert this into the php file of a page? Please email me and I can explain.

    Thank you!

  116. Is it possible to use it in the comments, too?

  117. 19
    Maxine

    Hi,
    This is a really great idea for a plugin but there’s just one problem: you state that the plugin allows you to have as many sections of expanding text on a page as you like. For me it only works with one…try to put in more than one section of text and the page just shows up in its entirety.

  118. I really dig this plugin but I’m having one problem. I’m using WP 2.6 and it works fine if I just use the html mode. However if I switch back to visual mode it strips the DDET tag. How do I remedy this or is there a way to use the shortcode tags [DDET] like other plugins.

  119. That´s just what I was looking for! :)
    Just one simple and dumb question: the search engines like google can “read” the text inside the “hidden box”??

    Tks!

  120. As mentioned below, I uploaded a new copy that does not use the str_ireplace function, which is only included in newer PHP versions. It now just uses str_replace.

    This is a PHP version issue, not a WordPress problem. Download the new copy and try it out.

  121. “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?

  122. 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?

  123. 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?

  124. 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.

  125. 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.

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

  127. 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!

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

  129. 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.

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

  131. 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.

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

  133. This doesnt seem to work in firefox?

  134. 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″

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

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.