您正在为传递数组post_status
错误的方式,这里我用更正更新了您的代码。
显示的列表pages
//To display list of pages
$args = array(\'post_status\' => array(\'drafts\', \'publish\'));
$pages = get_pages($args);
foreach ( $pages as $page ) {
// some html code that displays the page title
}
显示
Posts// To display list of posts
global $post;
$args2 = array(\'numberposts\' => 50, \'post_status\' => array(\'drafts\', \'publish\'));
$myposts = get_posts( $args2 );
foreach( $myposts as $post ) {
setup_postdata($post);
//... some HTML code to display the pages
}
请注意-您似乎对术语感到困惑
posts
和
pages
.
get_pages()
函数将返回页面,而不是帖子get_posts()
函数将返回POST