[wp-hackers] newlines from rich text editor do not convert to paragraphs

Davit Barbakadze jayarjo at gmail.com
Mon Dec 14 11:49:06 UTC 2009

> In visual mode single return inserts new paragraph

This is what wasn't working. But switching to default theme and
turning off plugins corrected this issue. So my guess here (proved by
some experiments) will be that using $post->post_content in the loop
directly will output not converted string (which our current theme
does intensively). Actual conversion as it seems is happening inside
the_content() tag (which is bypassed by our theme). And not inside
get_the_content(), but in the_content() tag only.

Update: Searching for filters attached to 'the_content' hook, brought
me to wp-includes/default-filters.php file, which is probably a
container for all default wordpress filters. And one of filters
attached to 'the_content' hook turned out to be wpautop() function
which does exactly that: "Replaces double line-breaks with paragraph

It means that only the_content() tag will output properly converted
content string, all other approaches to retrieving post content will
result in raw, unconverted text. Among others the_content() converts
text smilies into graphics, does some simple xhtml fixing and invalid
utf characters substitutions, and obviously much more.

It can be concluded from here that wordpresses unexplainable fault in
similar cases (which happen pretty often as I found out from my google
search activity), is, at least partially, untrue.

On Mon, Dec 14, 2009 at 12:05 PM, Andrew Ozz <admin at laptoptips.ca> wrote:
> mccormicky wrote:
>> I think I was going on about the html *mode* of the wp editor, not
>> *html*itself.
>> It's not a firefox only issue. I see this in safari and internet explorer.
>> Simple fix: use the html *mode of the editor* to insert line breaks by
>> *hitting
>> the return key*.
>> Then switch back to visual format  to do your rich text stuff * *then
>> switch
>> back to html mode* *and save.
>> if you save your changes in visual mode you run the risk of losing some
>> formatting.In this case, line breaks.
> I'm still not clear what the actual problem is... Dion explained quite well
> how the editors work: in HTML mode single return is converted to <br /> two
> returns are converted to <p>. In visual mode single return inserts new
> paragraph, and Shift+Return inserts <br />. Saving either in visual or HTML
> mode doesn't make a difference.
> If you're seeing something else, please disable all plugins and switch to
> the default theme to see if it makes a difference.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

Davit Barbakadze

More information about the wp-hackers mailing list