TinyMCE strips p tags after switching from visual to text mode
-
Here’s how you can reproduce the problem (which some in this forum had the audacity to label as a “feature”):
1. Create a new post
2. Go to the text/html mode
3. Type in: <p>Text</p>
4. Go to visual mode for a quick visual feedback.
5. Go back to text/html mode
6. The p-tags are GONE.Am I crazy for wanting this? Is this such an unusual behaviour? To want to type in some p-tags, switch between the modes, and have the p-tags preserved?
Please don’t suggest any of the following, because those arn’t acceptable solutions:
– Deactivating the visual mode (what the hell is it there for then?)
– Installing a plugin for this (you can’t be serious to suggest this)
– never switching from visual mode to text/html-mode (THIS IS NOT A SOLUTION!)
– Disabling all plugins and themes (seems to be the favourite answer in this forum, doesn’t help here)
– Disabling wpautop (wpautop converts double-line-breaks into p-Tags, how’s disabling that gonna help here?)What I have tried is putting this into my functions.php file:
add_filter('tiny_mce_before_init', 'tiny_mce_before_init_callback',100, 2); function tiny_mce_before_init_callback($settings, $editor_id) { $extended_valid_elements = "p"; if ( isset( $settings['extended_valid_elements'] ) ) { $settings['extended_valid_elements'] .= ',' . $extended_valid_elements; } else { $settings['extended_valid_elements'] = $extended_valid_elements; } return $settings; }
Now this didn’t solve it, but I think I may have made a mistake in there somewhere. Accoding to the docs on valid_elements and extended_valid_elements this should work. But it doesn’t.
- The topic ‘TinyMCE strips p tags after switching from visual to text mode’ is closed to new replies.