Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a plugin that will send tutorial emails to our users. These tutorials are created in wordpress and stored in wp_posts table in the database.

Of course I could simply run a query to get the post and that's it. But is there a special built-in function that I can use to get the post content after Wordpress post processing?

I am thing of using get_post but I'm not sure if this is the best thing to do:

<?php
$my_id = 7;
$post_id_7 = get_post($my_id); 
$post_content = $post_id_7->post_content;
?> 

Thanks for any tips.

share|improve this question
    
By "after post processing", do you mean you want the content with the html edited (<p> tags added, etc), or do you just mean after the post has been saved? –  jfacemyer Mar 5 '13 at 2:33
    
Yes I mean all formatting and all processing..not after the post has been saved. –  Codex Meridian Mar 5 '13 at 2:47

1 Answer 1

up vote 3 down vote accepted

If by "post processing" you mean the autoformatting, the shortcode processing, that sort of thing, then you want to pass the content through the the_content filters.

$my_id = 7;
$post_id_7 = get_post($my_id); 
$post_content = $post_id_7->post_content;
$post_content = apply_filters('the_content',$post_content);

http://codex.wordpress.org/Function_Reference/apply_filters

You can see much of what will be applied by default by looking at the source of wp-includes/default-filters.php. However, plugins and themes can add filters so you may find that you want to pick and choose what gets applieds.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.