我会使用REST API从每次安装中获取最新的10篇帖子,然后将这两个数组组合起来,按日期排序,然后只使用最新的10条结果。
$editorials = wp_remote_get( \'https://www.example.com/editorials/wp-json/wp/v2/posts/\' );
$news = wp_remote_get( \'https://www.example.com/news/wp-json/wp/v2/posts/\' );
$editorials = json_decode( $editorials[ \'body\' ] );
$news = json_decode( $news[ \'body\' ] );
$all = array_merge( $editorials, $news );
//* The spaceship operator requires PHP > 7.0
usort( $all, function( $a, $b ) { return $a->date <=> $b->date; } );
$all = array_slice( $all, 0, 10 );
//* Do something useful with the combined array of posts