It's a pretty well documented problem on the web: The post editor strips tags when switching between HTML and Visual. Has this issue been solved? Is there a way to stop markup manipulation when switching between the two modes yet?
It's a pretty well documented problem on the web: The post editor strips tags when switching between HTML and Visual. Has this issue been solved? Is there a way to stop markup manipulation when switching between the two modes yet?
This is actually expected behavior, not a problem. HTML view shows tags, while the Visual mode does not. Visual mode renders as closely as possible to how it will display on the webpage itself. The tags aren't stripped, they're incorporated into the markup that is rendered for Visual mode.
If you want to view the HTML markup, use the HTML mode. If you don't want to see it and want to edit your post like a Word Processor, then switch to Visual.
The problem is with people who switch between the HTML and Visual mode... Often times authors will paste in HTML, then switch to Visual mode. Then when I come in and switch back to HTML mode, the tags are gone. It wouldn't be such a hassle if the editor handled carriage returns more gracefully.
Could you give an actual example you have encountered of your tags that are gone?
If you want to, you could disable the visual editor in your profile settings within WordPress, so that there's no switching back and forth.
The Visual Editor is behaving exactly as it has been configured to behave. If you want it to behave differently, then you'll need to use a custom configuration, by filtering the $init array that gets passed to TinyMCE.
For example, to prevent TinyMCE from stripping IFRAMEs:
function mytheme_tinymce_config( $init ) {
$valid_iframe = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]';
if ( isset( $init['extended_valid_elements'] ) ) {
$init['extended_valid_elements'] .= ',' . $valid_iframe;
} else {
$init['extended_valid_elements'] = $valid_iframe;
}
return $init;
}
add_filter('tiny_mce_before_init', 'mytheme_tinymce_config');
(All inline comments removed to meet ten-line code limit. Let me know if you don't follow what's going on.)
I have a similar issue to nipponese where my <br> and <p> mark up gets stripped away and makes all the content in a list to then be one line/one big paragraph. I am trying to use wordpress as a simple way for my client to update their site. if they can't generate paragraphs and line breaks then it kind of defeats the purpose.
@chip if I make it so the "$init" array allows <br>` and <p> will it stop removing them when switching from visual to html?
I see this as a huge flaw.
@Phidahl if you use the code tags, then your <p> and <br> don't get parsed in these forums.
In WordPress, you don't need to add <p> and <br> tags. Just separate paragraphs by a double-return. When the post is parsed, WordPress should automatically include the <p> tags for you.
Seriously? I just learned this the hard way, I was preparing a page with Linked ID's and internal links (Glossary references and Top of page internal links), as soon as I switched to Visual mode, I lost all the markups, ridiculous...
WordPress Version 3.3.1
This has been driving me crazy for weeks now, I have tried everything I can find so far, disableing the wpautop() function, this tinymce advanced plugin, etc.
Chip Bennett, You are correct, TinyMCE executes a back-end filtration process which removes empty tags, and
tags from the post, when switching from the “Visual” to “HTML” tab in the editor in WordPress or vice-versa.
The only thing I found that worked was to create this: http://rich-stadnick.com/2012/02/wp-br-tags-fix-wordpress-from-auto-correcting-your-post-format/
Hope it help's you guys out, Phidahl this should fix your problem.
Rich
This topic has been closed to new replies.