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.
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