Friday, September 14, 2012

Get post content by ID in Wordpress

When we building a custom theme in wordpress, sometimes we need to get the title or content from a specific post in wordpress. Also sometimes, using a custom loop is the better option for us, but its hard when we need to get information from a specific post only,follow the instruction to overcome that



Just use the get_post_field() function. You can get the post content from it. Fine the following example which will display the content of the post with id $post_id:

echo get_post_field('post_content', $post_id);

Also, the function can be used to get other fields from the post. See the codex page for reference in wordpress.

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off