Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I always find myself in HTML mode in the editor to try and get simple things like breaks between paragraphs to show up right (using <p></p>). Is that normal? Is there a better editor out there that I could use?

share|improve this question

6 Answers 6

up vote 8 down vote accepted

What happens is that TinyMCE converts every double line break in the HTML source to <p></p> and vice versa. It will actually strip away any <p/> you manually enter in the HTML source after you save, because when the post's content is rendered, <p> and </p> will be added.

The auto-<p> replacement only works when you're rendering a post's content with <?php the_content() ?>, if you output $post->post_content directly, it won't go through the same formatting hooks and will look plain and without line breaks or paragraphs.

If what you want is lots of <br/> tags in the rendered markup, you should probably find a better solution based on CSS and the use of the margin or padding CSS properties.

share|improve this answer
2  
+1 the finest and correct way is with the possibilities of css; the markup is not for the view of a linebreak –  bueltge Aug 18 '10 at 20:31
1  
+1 from me as well because there should be no such thing like breaks between paragraphs in HTML. Add space with CSS. –  hakre Aug 24 '10 at 8:49

I agree with some of the above posts, as direct answers to the question (which assumes continued use of the WYSIWYG editor). But after trial, I have to recommend at least reconsidering, and switching to the HTML editor.

Assuming you're still with me (you're considering it as an option), there's more. "Ah," you say, "HTML editor still adds line breaks and generally messes with me!" True, which is why you need to remove the auto-p filter. For good measure, since I switch to as pure HTML as possible, I take out the texturizer, which handles things like curly quotes.

Go to your theme editor. Go to the "Theme Functions" (functions.php) file. Add the following:

remove_filter ('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');

But I also add this if I'm planning to use post/page excerpts:

remove_filter ('the_excerpt', 'wpautop');
remove_filter('the_excerpt', 'wptexturize');

Hope that helps! And frankly... I've never tried the disabling of filters alongside the visual editor! Maybe it actually DOES help in that regard as well!

share|improve this answer

I recommend TinyMCE Advanced as well, I prefer to have more control over the HTML code that is user editable on the site. There's an option Stop removing the P and BR tags when saving and show them in the HTML editor which will do the trick, it's unticked by default so once installed you need to go into the settings and enable it. Another advantage is the ability to show / hide various aspects of the editor so you can remove buttons that end users might potentially play around with and try to be 'creative' with their content formatting! A lot of the unwanted options are on by default so you need to go in and remove the options you don't want.

share|improve this answer

I use the Disable WPautop plugin, which, as expected, disables the wpautop function. That might be useful, depending on your situation.

share|improve this answer

In short: yes. That's normal.

No there are no better editors out there.

You might try TinyMCE Advanced and see if it helps.

Also, if you use backticks (`) on this site, it'll escape your html:

<br />

share|improve this answer

The reason you're having trouble is because WordPress prefers to use

tags, which are more semantic than line breaks.

share|improve this answer

Your Answer

 
discard

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.