[wp-testers] get_the_content usage question

Dougal Campbell dougal at gunters.org
Tue Mar 23 18:42:02 UTC 2010


On Mar 23 2010 12:54 PM, Paul Robinson wrote:
> Hi guys,
>
> I'm just wondering, is the entry in the codex for get_the_content
> still relevant where it tells you to add:
>
> <?php
> $content = apply_filters('the_content', $content);
> $content = str_replace(']]>', ']]&gt;', $content);
> ?>
>
> It says it hasn't been added to the core yet. Has it been added and
> the codex just hasn't been updated yet?
>    

I don't see that note on the Codex page.

But to answer your question: get_the_content() returns the content 
*before* filtering. So, if you are planning to send it out to the 
browser at some point, then yes, you probably want to do the steps above.

The template function the_content() does exactly that. It calls 
get_the_content(), then apply_filters(), then does the str_replace() to 
fix any parsing problems that might happen if you're trying to keep 
strict XML parsing.


-- 
Dougal Campbell <dougal at gunters.org>
http://dougal.gunters.org/
http://twitter.com/dougal
http://twitual.com/


More information about the wp-testers mailing list