web hosting
build a website

Add specific post to a page on wordpress

Aug 15, 2015   //   by Anthony Devine   //   Website Development tips  //  No Comments

The below code adds a specific post to a page on WordPress and it outputs the title and content:

<?php
$post_id = 18;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo $title;
echo $queried_post->post_content;
?>