我似乎无法让草稿与WP\\U查询一起显示,即使post\\U状态设置为“any”或“draft”
$args = array(
\'p\' => 1234,
\'post_type\' => \'any\',
\'post_status\' => \'any\'
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
// display the post
endwhile;
wp_reset_postdata();
如果我回去发布帖子1234,WP\\u Query会很好地抓住它。但当它是草稿时
any
也没有
draft
抓住它。
我读到exclude_from_search
中的参数register_post_type()
防止帖子显示在WP\\u查询中,因此我在从中获取的post\\u类型中将其设置为false,如下所示:
$args = array(
\'labels\' => $labels,
\'description\' => \'\',
\'public\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'show_ui\' => true,
\'menu_position\' => 60,
\'menu_icon\' => null,
\'capability_type\' => post,
\'hierarchical\' => false,
\'supports\' => array(\'title\', \'editor\', \'author\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'revisions\'),
\'rewrite\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'show_in_nav_menus\' => true,
);
register_post_type(\'chart\', $args);
这里有什么我忽视的吗?我不明白为什么这种帖子类型的草稿帖子不会出现在上面的查询中。