Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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,正在检索post值_Php_Wordpress_Post - Fatal编程技术网

Php Wordpress,正在检索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

我需要添加一些静态值,就像我们在java的属性文件中所做的那样

我怎样才能在Wordpress中做到这一点

我尝试了POST方法,但无法在前端检索POST值

谁能推荐一下吗

我尝试检索帖子,如下所示:

$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数组中,您使用草稿作为帖子状态,而您应该使用发布作为帖子状态。