您必须创建自定义分类:
add_action( \'init\', function(){
register_taxonomy( \'program\', \'your_post_type\', array() );
});
要获取与某个程序关联的用户,请获取所有包含所需程序术语的帖子:
$query = new WP_Query( array(
\'post_type\' => \'your_post_type\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'program\',
\'field\' => \'name\',
\'terms\' => \'your_program_name\',
),
),
) );
现在获取所有结果帖子的作者,这将为您提供与该特定程序关联的用户。
$posts = $query->posts;
foreach($posts as $post) {
$author = $post->post_author;
}