While performing custom programming, developers often want to access the content of a particular post. It is very easy to get content of a particular post. The only requirement is to have a valid Post ID. Each post is stored in the database with it's unique id that is needed to be passed in a core function of wordpress and retrieve it's content accordingly.
Below is the code that you can use to get content of a particular post:
// Setting the Post ID in a variable for which the content is required $the_postid = 20; $the_post_content = get_post($the_postid); $content = $the_post_content->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); // Print Content data or further use it as required echo $content;
View code on Github in PHP
Please note that the content will be in Raw HTML format as it is stored within a database. Now that you have the post content stored within a variable, it can easily be rendered or styled or further functions or actions can be performed as per developer's requirement.