如何只输出帖子内容(即输入到所见即所得的文本),而不输出其他内容?我只需要在特定类别的帖子中使用这个,所以如果我可以打电话说,
<?php get_template_part( \'venue_content\', \'single\' ); ?>
这将是理想的。如何只输出帖子内容(即输入到所见即所得的文本),而不输出其他内容?我只需要在特定类别的帖子中使用这个,所以如果我可以打电话说,
<?php get_template_part( \'venue_content\', \'single\' ); ?>
这将是理想的。假设您在循环中,或者知道(或知道如何获得)$post
对象:
function wpse63358_get_post_content() {
global $post;
return $post->post_content;
}
如果要格式化帖子内容,请替换此内容:return $post->post_content;
。。。使用此选项:return apply_filters( \'the_content\', $post->post_content );
要回显函数输出:echo wpse63358_get_post_content();
编辑注意:如果您只想在模板中输出帖子内容,实际上甚至不需要将其包装到函数中。简单使用:global $post;
echo apply_filters( \'the_content\', $post->post_content );
我认为你也可以使用“帖子格式”,无论是旁白格式还是引用格式,我相信都只会显示主要内容-http://codex.wordpress.org/Post_Formats
如果只想输出帖子内容,不包括任何短代码,请尝试以下操作。
global $post;
$postContentStr = apply_filters(\'the_content\', strip_shortcodes($post->post_content));
echo $postContentStr;