WordPress Tricks: How to call and display one specific post

Here is the line of code I use to display the content of one particular post somewhere on my WordPress website:

<?php
$post_id = 26;
$queried_post = get_post($post_id);
$content = $queried_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
?>

You will obviously need to replace the post ID (26) in the code above with the post ID of the post you want to call.

 

 

Related Posts:

Leave a Reply

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

*


*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">