获取与您需要使用的每个类别相关的帖子get_posts( $args ) 函数和in$args 您可以添加您的category\\u id
$args = array (
\'post_type\' => \'post\',
\'category\' => $cat_ID,
\'post_status\' => \'publish\',
);
$my_posts = get_posts( $args ); // return array of posts
// storing all post ID in an array
foreach( $my_posts as $my_post ) {
$post_cat_name[] = $my_post[\'ID\'];
}
所以在
$post_cat_name 它将存储与您的
$cat_ID如果你想为3个人做这些$cat_id, 然后可以循环上述代码3$cat_id 您可以使用$post_cat_name 数组作为2D array.