Display specific post in WordPress

To display a specific post by post ID, add the following code to your WordPress template file.

<?php
//Select specific post ID
$post_id=256;
//To display post title
echo '<h1>' . get_post($post_id)->post_title . '</h1>';
//To display post content
echo get_post($post_id)->post_content;
?>

Tested with WordPress 3.3

Leave a Reply

Your email address will not be published. Required fields are marked *