Processing WordPress’ Post Content

If you find yourself directly manipulating a WordPress post (say outside of “The Loop” by using query_posts, e.g. query_posts(array('category__and' => array(1,3)));) you may need to do some extra work to get the pretty formatting that WP does for you in things like the_content() and the_excerpt().

Say you have a single post in a local variable $my_post, if you want to output the content of the post and use the filters that WP does for you when calling the_content within The Loop, you can call the filter functions directly:

<?php echo wpautop(wptexturize($framing_post->post_content)); ?>

References: How WordPress Processes Post Content, Function Reference/wptexturize, Function Reference/wpautop, formatting.php source code


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s