当我在插件页面上使用此代码时,我得到的是空数组,但不是所需的结果。
这个代码怎么了?
$defaults_arr = array(
\'post_type\' => \'at-subscription\',
\'suppress_filters\' => true,
\'order\' => \'ASC\',);
//
$query_r = wp_parse_args($args,$defaults_arr);
$get_posts = new WP_Query();
print_r($get_posts->query($query_r));
SO网友:Aftab
你可以这样写
$args = array(
\'posts_per_page\' => 10, // -1 to fetch all posts
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'post_type\' => \'at-subscription\', // the post type
\'post_status\' => \'publish\',
\'suppress_filters\' => true
);
$posts_array = get_posts( $args );
// For displaying all posts related to at-subscription
print_r( $posts_array );
希望这对你有帮助。谢谢