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 badges2 Answers
Reset to default 1Well, 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(']]>', ']]>', $content);
echo $content;
?>
本文标签: Get post content from outside the loop with plugin shortcode usability
版权声明:本文标题:Get post content from outside the loop with plugin shortcode usability 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741809770a2398724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论