Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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!

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.

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 />

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

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

tags, which are more semantic than line breaks.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top