Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm not sure if is wordpress itself or Tiny MCE that's doing it. But when switching between HTML and Visual editor it's adding  , and adding an extra one each time I switch back and forth. I don't even have a line break in the code, it seems to somehow be deciding where it wants to place them based on the tags in my html code.

What's causing this and how do I fix it?

I've already tried this in the template functions file:

//disable auto p
remove_filter ('the_content', 'wpautop');
remove_filter ('comment_text', 'wpautop');
// Remove auto formatting
remove_filter('the_content', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
remove_filter('the_title', 'wptexturize');
share|improve this question

migrated from Sep 28 '11 at 11:22

This question came from our site for professional and enthusiast programmers.

It's actually doing this automatically when you switch tabs, I noticed it too, and found it very annoying. No clue on how to fix it yet though... –  Joost de Valk Sep 28 '11 at 15:17
I use the HTML editor almost exclusively, pasting code in there from BBEdit. It seems to do this to me when I save in WP. –  neilfein Oct 25 '11 at 19:30
well I have this problem too. When I post manually and click enter button, it will add paragraph for me. This happens after i installed tiny mce. What do you mean by this anyway: Filter tiny_mce_init, to override the default content-filtering rules –  user15672 Apr 30 '12 at 10:19

3 Answers 3

up vote 1 down vote accepted

All I use is remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); and that stops Wordpress from creating any extra markup. Are you copying and pasting your code from an external editor?

share|improve this answer
didn't work for me. Without using Tiny MCE, just in HTML each "update" still adds new  s –  Christian Jun 17 '12 at 14:34

What's causing this and how do I fix it?

Any content added to or removed from your Post Content is caused by tiny_mce_init, which is applying is's content-filtering rules.

The ways to prevent it are:

  1. Filter tiny_mce_init, to override the default content-filtering rules
  2. Stop switching between Visual and HTML editors. Really; unless you want to use option #1 above, don't switch between editors. WordPress is intended to be used such that content is entered using the Visual or the HTML editor, but not both simultaneously.

Example use for the tiny_mce_before_init filter in Codex. Another example of TinyMCE configuration/customization in Codex here.

share|improve this answer
I'm pretty sure that your #2 answer is wrong. That or someone "screwed the pooch" on the UI. If the editor was intended to only be used as Visual or HTML, why have the Tabs there at all? Why not just have it as an option under settings to use it one way or the other? Further more, the tabs are there by default... it's not some developer advanced feature or option you have to setup. I'm pretty sure they where intended for users to be able to click back and forth between and that the real problem is that sometimes they don't work well together. (especially in the case of space formatting) –  luckykind Nov 18 '11 at 3:43
@luckykind No, they weren't intended to switch forth and back between them. That's just a TinyMCE architectural problem. And it's not the only one. –  kaiser Oct 2 '13 at 12:38

In css file. Put display: inline-flex to the p inside the excerpt. The additional white spaces don’t bother anymore. works for me

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.