オーケー、これが状況です.... 私は自分のビジネスのウェブサイトに取り組んでいます。ワーク/ポートフォリオエリアがあります。「仕事」はカスタム投稿タイプです。「デザイナー」はカスタム ユーザー ロールです。「クライアント」はカスタム ユーザー ロールです。
新しい「作品」投稿を作成する際に、通常の投稿に著者を割り当てるように、作品に割り当てる「デザイナー」と「クライアント」の両方を選択できるようにしたいと考えています。
この回答の方法を試しましたが、うまくいきませんでした。) functions.php ファイルに配置しました。
` add_filter('wp_dropdown_users', 'test'); function test($output) { グローバル $post;
//Doing it only for the custom post type
if($post->post_type == 'work')
{
$users = get_users(array('role'=>'designer'));
//We're forming a new select with our values, you can add an option
//with value 1, and text as 'admin' if you want the admin to be listed as well,
//optionally you can use a simple string replace trick to insert your options,
//if you don't want to override the defaults
$output .= "<select id='post_author_override' name='post_author_override' class=''>";
foreach($users as $user)
{
$output .= "<option value='".$user->id."'>".$user->user_login."</option>";
}
$output .= "</select>";
}
return $output;
}
`
どんな助けでも大歓迎です!