Resolving Unexpected Code and Tags in Your WordPress Editor
Content
Many WordPress users rely on the Advanced Editor Tools plugin (formerly TinyMCE Advanced) to enhance their editing experience. However, it's not uncommon to encounter strange code snippets, unexpected HTML comments, or tags that seem to appear or disappear mysteriously. This guide will help you understand why this happens and how to resolve the most common issues.
Common Symptoms and Their Causes
Based on community reports, the most frequent issues include:
- Unexpected HTML comments like
<!--mep-nl-->or<!--mep-tab-->appearing in the Text view. - Strange
<span>tags being inserted, often containing attributes likedata-mce-type="bookmark"orclass="mce_SELRES_start". - Essential tags, such as
<p>(paragraph) or<br>(line break), being stripped out when saving content. - JavaScript code or specific HTML elements being removed or altered upon saving.
It is crucial to understand that Advanced Editor Tools is often not the primary cause of these issues. The WordPress editor is a complex system where your theme and multiple plugins interact. These symptoms are typically the result of one of three things:
- Plugin Conflicts: Another plugin is modifying editor behavior. The
<!--mep-nl-->tags, for instance, are known to be inserted by the 'Preserved HTML Editor Markup' plugin and can conflict with Advanced Editor Tools. - Browser Extensions: Extensions like the Pinterest Save button can inject their own code (
<span>tags with specific styles) into every textarea on a webpage, including your WordPress editor. - Core WordPress or TinyMCE Behavior: WordPress has built-in security functions that sanitize content by removing certain tags and attributes, especially JavaScript event handlers like
onclick.
Step-by-Step Troubleshooting Guide
Follow these steps to identify and fix the source of the problem.
Step 1: Check Advanced Editor Tools Settings
First, verify a key setting within the plugin itself. This can resolve issues with missing paragraph tags.
- Navigate to Settings → Advanced Editor Tools in your WordPress dashboard.
- Go to the Classic Paragraphs or Editor tab.
- Ensure the option labeled Stop removing the <p> and <br> tags or similar is checked.
- Save your changes.
Step 2: Perform a Conflict Test
This is the most effective way to determine if another plugin or your theme is causing the issue.
- Deactivate all plugins except Advanced Editor Tools.
- Switch to a default WordPress theme like Twenty Twenty-Four.
- Check if the problem persists.
- If the issue is gone, one of the deactivated components is the culprit.
- Reactivate your plugins one by one, checking the editor after each activation, until the problem returns. The last plugin you activated is likely causing the conflict.
- If the problem remains after deactivating all plugins, try switching to a default theme to rule out your theme as the cause.
Step 3: Check Your Browser
If you are seeing specific <span> tags with styles for a 'Save' button, this is almost certainly caused by a browser extension.
- Open your WordPress editor in a different browser where you don't have many extensions installed (e.g., Chrome vs. Firefox).
- If the problem does not appear in the other browser, disable your extensions one by one in the original browser to find the one injecting code. Common suspects are Pinterest, Grammarly, or other content-saving extensions.
Step 4: Understand WordPress Limitations
For issues involving stripped JavaScript (like onclick events), it's important to know that this is a security feature of WordPress, not a bug in the plugin. The editor is designed to remove potentially malicious code. To add custom scripts, you should:
- Use a dedicated plugin for adding custom code snippets site-wide.
- Add the code directly to your theme's template files (if it's for a specific design element).
- Use a custom HTML widget or block for simple embed codes.
Conclusion
Unexpected code in the editor is almost always a symptom of a conflict elsewhere in your WordPress setup. By methodically testing your plugins, theme, and browser, you can identify the true source. The Advanced Editor Tools plugin provides valuable enhancements, but it operates within a larger ecosystem. Isolating the conflict is the key to a clean and predictable editing experience.
Related Support Threads Support
-
Line numbers in the text editor?https://wordpress.org/support/topic/line-numbers-in-the-text-editor/
-
Tags being added into codehttps://wordpress.org/support/topic/tags-64/
-
why does the editor add comments all over the place in the htmlhttps://wordpress.org/support/topic/why-does-the-editor-add-comments-all-over-the-place-in-the-html/
-
suddenly expands inside [code] tags?https://wordpress.org/support/topic/suddenly-expands-inside-code-tags/
-
tags getting stripped outhttps://wordpress.org/support/topic/tags-getting-stripped-out/
-
Caption tag displays what looks like bbcodehttps://wordpress.org/support/topic/caption-tag-displays-what-looks-like-bbcode/
-
Code added <span data-mce-type="bookmark"https://wordpress.org/support/topic/code-added-span-data-mce-typebookmark/
-
Javascript is being stripped out of pageshttps://wordpress.org/support/topic/javascript-is-being-stripped-out-of-pages/
-
“Save” span being created?https://wordpress.org/support/topic/save-span-being-created/
-
URL auto loads sitehttps://wordpress.org/support/topic/url-auto-loads-site/
-
Tags go missing when displayinghttps://wordpress.org/support/topic/tags-go-missing-when-displaying/
-
iframe code snippet changes itselfhttps://wordpress.org/support/topic/iframe-code-snippet-changes-itself/
-
How to add more tags?https://wordpress.org/support/topic/how-to-add-more-tags/