最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Get post content from outside the loop with plugin shortcode usability

programmeradmin1浏览0评论

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;
?>
发布评论

评论列表(0)

  1. 暂无评论