我创建了一个称为组的自定义帖子类型。我想在组编辑页面中提供向这些组添加用户的选项。如有任何帮助,我们将不胜感激。谢谢。P、 S:我想过使用Post-to-Post插件,但我不确定这是否是正确的解决方案。
将WordPress用户添加到自定义帖子类型
1 个回复
SO网友:Gufran Hasan
您可以使用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
发布后,您将在下拉列表中看到用户列表:重要细节:结束