使用自定义SQL查询获取具有唯一作者的最新16个帖子ID;
$post_IDs = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = \'product\' AND post_status = \'publish\' GROUP BY post_author ORDER BY post_date DESC LIMIT 16" );
然后使用
post__in
论点
$recent_posts = new WP_Query( array( \'post__in\' => $post_IDs, \'post_type\' => \'product\' ) );