我刚刚找到了另一种解决方案:
global $post;
$current_post = $post->ID;
$array=range(1,$current_post);
$args = array(
\'numberposts\' => 5,
\'offset\' => 0,
\'category\' => $category->term_id,
\'orderby\' => \'ID\',
\'order\' => \'DESC\',
\'exclude\' => $current_post,
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'suppress_filters\' => true,
\'post__in\' => $array );
$posts = get_posts($args);
我不知道为什么以前的方法不起作用。无论如何,我已经解决了这个问题。感谢@imHavoc和@userabuser查看我的问题:)