WordPress Get Page Content By Page Id

posts .
            ' WHERE ' . $wpdb->posts . '.ID=' . $pageId;
            $post_data = $wpdb->get_results($nsquery);
            if(!empty($post_data))
            {
                foreach($post_data as $post)
                {
                    $text_out=nl2br($post->post_content);
                    $text_out=str_replace(']]>', ']]>', $text_out);
                    $text_out = strip_tags($text_out);
                    return substr($text_out,0,$max_char);

                }
            }
        }
}
?>

Call the above function in your page:

//First parameter is PAGE ID and second is number of words displayed. ?>
0

About the author

Janaki(http://mjanaki.com) - A Software developer with 9+ years of experience in multiple technology projects across web, mobile, and cloud applications with expertise in PHP, C#, MySQL, Web services and open source platforms.

Similar Posts

Query X Number of Recent Posts
WordPress Tricks

Leave a reply

required*

Eye Test: * Time limit is exhausted. Please reload CAPTCHA.