可以指定参数post_type
对于函数get_posts()
(参见all available arguments 此处)。所以这条线
$posts = get_posts( array( \'numberposts\' => -1, \'post_status\' => \'any\' ) );
将成为这条线
$posts = get_posts( array( \'numberposts\' => -1, \'post_status\' => \'any\', \'post_type\' => \'portfolio\' ) );