I have to get specific page content (like page(12))
I used that :
post_content; ?>
The wp_trim_words function can limit the characters too by changing the $num_words variable. For anyone who might find useful.
<?php
$id=58;
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
$customExcerpt = wp_trim_words( $content, $num_words = 26, $more = '' );
echo $customExcerpt;
?>
get page content by page name:
<?php
$page = get_page_by_title( 'page-name' );
$content = apply_filters('the_content', $page->post_content);
echo $content;
?>
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'prev_text' >' Previous','post_type' => 'page', 'posts_per_page' => 5, 'paged' => $paged );
$wp_query = new WP_Query($args);
while ( have_posts() ) : the_post();
//get all pages
the_ID();
the_title();
//if you want specific page of content then write
if(get_the_ID=='11')//make sure to use get_the_ID instead the_ID
{
echo get_the_ID();
the_title();
the_content();
}
endwhile;
//if you want specific page of content then write in loop
if(get_the_ID=='11')//make sure to use get_the_ID instead the_ID
{
echo get_the_ID();
the_title();
the_content();
}
A simple, fast way to get the content by id :
echo get_post_field('post_content', $id);
And if you want to get the content formatted :
echo apply_filters('the_content', get_post_field('post_content', $id));
Works with pages, posts & custom posts.
Just only copy and paste this code it will get your page content.
<?php
$pageid = get_the_id();
$content_post = get_post($pageid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
?>
I used this:
<?php echo get_post_field('post_content', $post->ID); ?>
and this even more concise:
<?= get_post_field('post_content', $post->ID) ?>