{"id":4800,"date":"2015-10-11T12:49:20","date_gmt":"2015-10-11T12:49:20","guid":{"rendered":"https:\/\/www.techrounder.com\/blog\/wordpress-function-to-get-post-content-by-post-id\/"},"modified":"2026-01-04T11:36:56","modified_gmt":"2026-01-04T11:36:56","slug":"wordpress-function-to-get-post-content-by-post-id","status":"publish","type":"post","link":"https:\/\/www.techrounder.com\/blog\/wordpress-function-to-get-post-content-by-post-id\/","title":{"rendered":"WordPress Function to Get Post Content by Post ID"},"content":{"rendered":"<p>In WordPress, we can get the content of the post ID by custom WordPress function. For that, add the following code in the template file and function in the theme folder.<\/p>\n<p>1. Add the following code in the template file where the post content is to be displayed.<\/p>\n<p><code>$postID = 12<br \/>\necho get_post_content_by_id($postID); <\/code><\/p>\n<p>Here $postID is the iD of the post, of which the content is to be displayed. <\/p>\n<p>2. Add the following function definition in the function.php file in the theme folder. <\/p>\n<p><code>function get_post_content_by_id($postID) {<br \/>\n\t$content_post = get_post($postID);<br \/>\n\t$content = $content_post->post_content;<br \/>\n\t$content = apply_filters('the_content', $content);<br \/>\n\t$content = str_replace(']]>', ']]&gt;', $content);<br \/>\n\treturn $content;<br \/>\n}<\/code><\/p>\n<p>This function will return the content of the corresponding post id.<\/p>\n","protected":false},"excerpt":{"rendered":"In WordPress, we can get the content of the post ID by custom WordPress function. For that, add&hellip;","protected":false},"author":2,"featured_media":106,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"csco_display_header_overlay":false,"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","csco_post_video_location":[],"csco_post_video_location_hash":"","csco_post_video_url":"","csco_post_video_bg_start_time":0,"csco_post_video_bg_end_time":0,"csco_post_video_bg_volume":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-4800","post","type-post","status-publish","format-standard","has-post-thumbnail","category-wordpress","cs-entry","cs-video-wrap"],"_links":{"self":[{"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/posts\/4800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/comments?post=4800"}],"version-history":[{"count":0,"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/posts\/4800\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/media\/106"}],"wp:attachment":[{"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/media?parent=4800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/categories?post=4800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techrounder.com\/blog\/wp-json\/wp\/v2\/tags?post=4800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}