TinyMCE Entities Patch Plugin

Important Note: The recent release of WordPress 2.6 has fixed the disappearing entities bug this plugin was designed to fix, so once you upgrade to WordPress 2.6 please discontinue using this plugin.  I may release a new plugin that prevents spaces from being stripped from the beginning of lines sometime in the near future.

Announcing the TinyMCE Entities Patch Plugin. 

Prevent spaces and HTML entities (e.g. > or ') from disappearing when editing posts with TinyMCE.

After a few weeks of writing posts on WordPress, I was getting very irritated when all the HTML entities I added to my examples kept being converted into characters — e.g. HTML entities like &gt; &lt; &quot; would convert to > < “ when I saved the post I was working on. 

To make matters worse, all the spaces I was using to align my coding examples would disappear when switching between “HTML” mode and “Visual” mode, even if I used the &nbsp; entity.

So, I finally bit the bullet and wrote this little plugin to fix these problems.  It does just two things:

  • Allows you to enter HTML entities like &gt; &lt; &amp; etc. while in “Visual” mode and they will stay put, even after you save your post.
  • Allows you to type extra spaces while in “Visual” mode (or &nbsp; in “HTML” mode) and they will stay put too, allowing you to correctly indent code samples, etc.

If you are writing blog posts with source code or HTML examples, you may find this little plugin helps you avoid a ton of aggravation.  This blog page was written with this plugin enabled.  Believe me, it made writing it a whole lot easier.

The plugin works with TinyMCE or the TinyMCE Advanced plugin.

Please note, this plugin is a patch for issues with WordPress’s uses of TinyMCE, and not the editor itself.

(Not tested on any version of WordPress older than 2.5.1.  It may work on earlier versions, but I just don’t know for sure.  Try it and see.  If it doesn’t work simply deactivate the plugin.  If it does work, please let me know!!)


Here are the instructions for installing the plugin:

  1. Download the latest plugin zip file.
  2. Upload the plugin contents into your WordPress installation’s plugin directory.
  3. The plugin’s .php file and readme.txt should be installed in the ‘wp-content/plugins/tinymceentities/’ directory.
  4. From the Plugin Management page, activate the TinyMCE Entities Patch plugin.

That’s all there is to it.  Next time you edit a post or page, when you add HTML entities (like &gt; or &lt;) or extra spaces they will remain as typed when you save and edit again later.

6 thoughts on “TinyMCE Entities Patch Plugin

  1. WBMike

    You know what, I’ve been thinking about this for a while now. I just hate when I’m trying to make a blank paragraph with &nsbp and it just disappears when i switch back and forth.

  2. Pingback: Multiple spaces in Wordpress posts « Naatan.com - Opensource Web Developer

Leave a Reply to baron Cancel reply

Your email address will not be published. Required fields are marked *