I’m really frustrated with WordPress visual editor right now. Whenever I toggle between the visual mode and text mode, it keeps removing certain HTML elements from my content. This happens every single time I switch back and forth between these two editing modes.
The main issue is that specific tags get stripped out automatically. I understand there’s an option to completely turn off the visual editor, but I don’t want to do that. I actually like using the visual editor for most of my writing.
Is there some kind of solution or plugin that would let me keep the visual editor but stop it from automatically cleaning up my HTML code? I need those tags to stay in place for my content to work properly.
This drove me crazy too. I fixed it by installing TinyMCE Advanced and tweaking the settings. Enable “Keep paragraph tags in the Classic block and the Classic Editor” - that’s key. Also hit the Advanced Options tab and tell it which HTML tags to preserve (WordPress strips out a bunch by default). I also added a snippet to my theme’s functions.php to extend the allowed HTML tags for the visual editor. You can filter wp_kses_allowed_html to include whatever tags you need. Just backup your site first before messing with the functions file.
Had the same issue building custom layouts with specific div structures. Fixed it by adding a filter to functions.php that stops WordPress from sanitizing certain tags. Hook into tiny_mce_before_init and modify the valid_elements parameter. I added $init['valid_elements'] .= ',div[*],span[*]'; to keep my custom markup. The asterisk tells TinyMCE to preserve all attributes for those tags. Also check your theme - some have their own content filters that strip HTML separately from the editor. This was happening to me even without switching views, just on post save.
WordPress content filters are screwing this up, not TinyMCE. I wasted weeks tweaking editor settings before figuring out WordPress sanitizes everything when you save, no matter what editor you’re using. Here’s what actually worked: create a custom post meta field for your raw HTML instead of putting it in the main content. When you need those tags preserved, dump that content in the meta field and use a shortcode or template function to display it. This skips WordPress filtering entirely while you can still use the visual editor for normal stuff. The meta field never gets touched by wpautop or kses so your HTML stays put. Way easier than battling the core system.
Been there. You’re fighting WordPress instead of working with it.
I fixed this by automating content sync between my local editor and WordPress. Skip the built-in editor completely. Write everything with proper HTML in your editor, then push it straight to WordPress via API.
The automation preserves formatting and dodges all TinyMCE cleanup garbage. No stripped tags, no switching problems. You can still use the visual editor for quick tweaks, but complex HTML stays put.
This beats patching functions.php or wrestling TinyMCE settings every WordPress update. Set it once, forget editor limits forever.
Latenode makes this dead simple with WordPress integrations. Build the whole sync workflow in minutes, zero code needed.
same issue here for months! switching to gutenberg blocks fixed it for me. the HTML block doesn’t strip your code when you toggle between visual and code views. way better than constantly fighting TinyMCE.