How to replace the content of tinyMCE editor in both text and visual mode using jQuery?

The first thing to do is to select the active editor. Here we select the editor using its id, which is content. var activeEditor = tinyMCE.get(‘content’); Then we use tinyMCE’s setContent: var activeEditor = tinyMCE.get(‘content’); var content=”HTML or plain text content here…”; activeEditor.setContent(content); However, if the editor is in text mode to begin with, after … Read more

WordPress Visual Editor Stripping HTML Changes

Background This issue revolves around the removal of empty <span></span> elements in TinyMCE when saving a post or switching between between the Visual and Text editor tabs. The problem is inherent to core functionality (as of trunk version 4.0-alpha-20140602) and is unchangeable via the standard WordPress APIs, as is mentioned in ticket #26986. The ticket … Read more