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

Jeremy Clarke jer at simianuprising.com
Fri Dec 18 18:57:04 UTC 2009

On Tue, Dec 15, 2009 at 1:45 PM, scribu <scribu at gmail.com> wrote:
> On Tue, Dec 15, 2009 at 6:05 PM, Ken Newman <Ken at adcstudio.com> wrote:
>> You can apply the filter yourself:
>>> $filtered_content = apply_filters('the_content', get_the_post_content());
>>>  Would it be considered good practice do this, say, in child theme's
>> function file?
> Yes, it doesn't matter where you're putting this code.

I think this is the right approach. I do the
apply_filters('the_content', $something) trick often to get things
like [shortcodes] to work in category descriptions, author bios etc.

It's not really Ideal as its supposed to be tied to showing post body
content, but in practice it tends to work really well. Most plugins
add their filtering to that hook so whatever you pass in gets the full
treatment in most cases.

Moving the default filters to get_the_content() seems dangerous to me,
especially for reverse compatibility. Past uses of that filter would
assume specifically that the content would NOT have paragraphs etc
added to it, which could be important for a lot of reasons. It's also
logically consistent that get_the_content() would return the
database-formatted text, there are lots of situations where that is a
valuable tool and taking care of the filtering yourself after is
reasonable if you are being that elaborate with your manipulations.

Obviously themes shouldn't mess around with $post->post_content unless
they know what they're doing. I can't help thinking that adding that
to a theme without any add_filter('the_content') must have been done
with almost no testing of its effects on posting (I've done this
before! It caused bugs cause I did almost no testing of posting!)

Jeremy Clarke | http://jeremyclarke.org
Code and Design | http://globalvoicesonline.org

More information about the wp-hackers mailing list