I've a hard time googling for this issue. On my blog, whenever I update an existing page, code sections are doubly escaped. I.e., on a recent page I have

find /V "QWERTYUIOPPO" < calc.exe:yourads.txt

and after a recent edit it has become:

find /V &quot;QWERTYUIOPPO&quot; &lt; calc.exe:yourads.txt

When I save it once more, it will escape the entities once more:

find /V &amp;quot;QWERTYUIOPPO&amp;quot; &amp;lt; calc.exe:yourads.txt

Etc. Needless to say this is nasty. For pages containing a lot of code this is a real bummer. Until now I just did some search and replace actions, but this can't stay forever. Does anybody recognize this issue?

Here's an example page that illustrates this issue. Also in the screenshot for future reference (as I sure hope to solve the issue on my pages sometime soon).

enter image description here


I face this issue quite often on my own site where I publish code tutorials. Unfortunately, there isn't a good solution. Instead, I recommend this workflow:

  • Use the WYSIWYG editor to build your article content leaving placeholders for your code snippets.
  • Switch to the HTML editor to add your code snippets

The visual editor (TinyMCE) tries to escape code-like characters for display. It wasn't meant for writing code snippets in the first place.

  • That makes it hard to re-edit pages, especially in situations where the article is larded with many small snippets. There are so many coders using wordpress, didn't anybody ever write a hook for this, unescaping <pre> or [code] blocks? – Abel May 4 '12 at 19:18
  • It has nothing to do with WordPress, it's all the TinyMCE WYSIWYG editor. And most developers who blog with WordPress use the HTML view rather than the visual editor in the first place. – EAMann May 4 '12 at 19:22
  • Yeah, I've gotten lazy ;). However, why does it work correctly the first time around, but not when you edit again? Just wondering. – Abel May 4 '12 at 19:30
  • 1
    Each time you load the page, the raw text is passed through TinyMCE and manipulated by the editor to display in the window. So if you type in < the first time and click "save", TinyMCE converts this to &lt; and WP stores that in the database. When you load it, WP reads this back out and TinyMCE displays it on the screen. But to display &lt; on the screen, you escape the ampersand, so TinyMCE converts it to &amp;lt;. When you click "save" again, WP stores this value instead. It's a snowballing problem from there ... – EAMann May 4 '12 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.