Php Wordpress,正在检索post值
我需要添加一些静态值,就像我们在java的属性文件中所做的那样 我怎样才能在Wordpress中做到这一点 我尝试了POST方法,但无法在前端检索POST值 谁能推荐一下吗 我尝试检索帖子,如下所示:Php Wordpress,正在检索post值,php,wordpress,post,Php,Wordpress,Post,我需要添加一些静态值,就像我们在java的属性文件中所做的那样 我怎样才能在Wordpress中做到这一点 我尝试了POST方法,但无法在前端检索POST值 谁能推荐一下吗 我尝试检索帖子,如下所示: $args = array( 'slug' => 'cpurl', 'post_type' => 'cpurl', 'post_status' => 'draft', 'numberposts' => 1 ); $my_posts = get
$args = array(
'slug' => 'cpurl',
'post_type' => 'cpurl',
'post_status' => 'draft',
'numberposts' => 1
);
$my_posts = get_posts($args);
print_r ($my_posts);
显示空数组
$postid = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_title = '" . $postTitle . "'" );
$content_post = get_post($postid);
$cpUrl = $content_post->post_content;
使用上述代码获取文章内容,使用可用的内容标题您是否已将文章保存为草稿或已发布?您的代码对我来说运行良好。我不知道为什么它对你不起作用。我认为您已经发布了您的帖子,但在$args数组中,您使用草稿作为帖子状态,而您应该使用发布作为帖子状态。