wp get page content by id code example

Example 1: wp get post content by id

$post_id = 5// example post id
$post_content = get_post($post_id);
$content = $post_content->post_content;
echo apply_filters('the_content',$content);

Example 2: wordpress get particular page content programmatically

<?php 
$id=47; 
$post = get_post($id); 
$content = apply_filters('the_content', $post->post_content); 
echo $content;  
?>

Example 3: wordpress get particular page content programmatically

<?php

// would echo post 7's content up until the <!--more--> tag
$post_7 = get_post(7); 
$excerpt = $post_7->post_excerpt;
echo $excerpt;

// would get post 12's entire content after which you
// can manipulate it with your own trimming preferences
$post_12 = get_post(12); 
$trim_me = $post_12->post_content;
my_trim_function( $trim_me );

?>

Tags:

Php Example