您可以使用ACF plugin
对于https://wordpress.org/plugins/advanced-custom-fields/.
需要执行的步骤:
下载并安装ACF插件点击Custom Fields
左侧菜单中的链接将自定义字段添加为:选择“自定义为”并将其发布:现在将此代码添加到functions.php
文件名:
function acf_load_color_field_choices( $field ) {
// reset choices
$field[\'choices\'] = array();
$blogusers = get_users();
$field[\'choices\'][0] = "Select User";
foreach($blogusers as $user){
// append to choices
$field[\'choices\'][ $user->ID ] = $user->display_name;
}
// return the field
return $field;
}
add_filter(\'acf/load_field/name=select_user_for_post\', \'acf_load_color_field_choices\');
如果您创建
Groups
发布后,您将在下拉列表中看到用户列表:
重要细节:
get user list
Dynamically populate a select field’s choices