Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 尝试在wordpress中获取帖子正文,但不起作用_Php_Wordpress - Fatal编程技术网

Php 尝试在wordpress中获取帖子正文,但不起作用

Php 尝试在wordpress中获取帖子正文,但不起作用,php,wordpress,Php,Wordpress,我是wordpress的新手,正在尝试获得博文正文。 我是这样做的 我使用的主题是ClassID 他们就这样到了那里 $plan_featured_ads = get_post_meta($post->ID, 'featured_ads', true); 使用同样的方法,我不会得到帖子正文 $post_content = get_post_field($post->ID, 'post_content'); 这不会返回任何结果,我做错了什么 看起来您已经在$Post中获得了一个W

我是wordpress的新手,正在尝试获得博文正文。 我是这样做的 我使用的主题是ClassID 他们就这样到了那里

$plan_featured_ads = get_post_meta($post->ID, 'featured_ads', true); 
使用同样的方法,我不会得到帖子正文

$post_content = get_post_field($post->ID, 'post_content');

这不会返回任何结果,我做错了什么

看起来您已经在$Post中获得了一个WP_Post实例,因此要访问Post_内容,您可以执行以下操作:

// If you need an un-filtered version of the post:
$post->post_content;

// If you need a filtered version of the post for displaying on screen:
apply_filters('the_content', $post->post_content);