admin管理员组

文章数量:1305831

This is great for showing just the raw content... Get post content from outside the loop But i'd also like to apply shortcodes from various plugins to my content to affect the content. What would I need to do to allow this?

This is great for showing just the raw content... Get post content from outside the loop But i'd also like to apply shortcodes from various plugins to my content to affect the content. What would I need to do to allow this?

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Oct 9, 2015 at 7:12 PetePete 1,0582 gold badges14 silver badges40 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Well, you can do this with much less code:

echo apply_filters( 'the_content', get_post_field('post_content', $post_id) );

You can also use get_post_field function to get other fields like post_title, and so on.

This works...

<?php
$post_id = 956; // <<<< change page id here
$queried_post = get_post($post_id);
$content = $queried_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
?>

本文标签: Get post content from outside the loop with plugin shortcode usability