Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can i get wordpress posts content by post id?

share|improve this question
[code] $postsubtitrare = get_post_meta($post->ID, 'id-subtitrare', true); $content = the_content( $postsubtitrare ); echo $content;[/code] what do you say about this to show the content of posts by post id using custom fields? what is wrong whit this code? – m3tsys Feb 19 '11 at 11:29

2 Answers

up vote 28 down vote accepted

Simple as it gets

$my_postid = 12;//This is page id or post id
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
share|improve this answer
11  
Shorthand for specific field: $content = get_post_field('post_content', $my_postid); – Rarst Feb 17 '11 at 21:39
echo get_post_field('post_content', $post_id);
share|improve this answer
1  
better to do it like echo apply_filters('the_content', get_post_field('post_content', $post_id));. For example when using qTranslate, your solution would not be enough. – Karel Attl Jan 17 at 7:10

protected by Community Nov 27 '12 at 19:56

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

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