在自定义主题中添加用户列表下拉列表

 $wp_customize->add_control( new WP_Customize_Control(
 $wp_customize,//Pass the $wp_customize object (required)
 'user_theme_name',//Set a unique ID for the control
 array(
    'label'      => __( 'Select Theme Name','user' ),//Admin-visible name of the control
    'description' => __( 'Using this option you can change the user' ),'settings'   => 'bootstrap_theme_name',//Which setting to load and manipulate (serialized is okay)
    'priority'   => 10,//Determines the order this control appears in for the specified section
    'section'    => 'user_options',//ID of the section this control should render in (can be one of yours,or a WordPress default section)
    'type'    => 'select','choices' => array(
        'default' => 'admin','cerulean' => 'Cerulean','cosmo' => 'Cosmo','cyborg' => 'cyborg',)
)
) );

我已经在自定义主题中创建了一个下拉菜单,但是我无法获取用户列表并将其放在下拉菜单中。我尝试添加此钩子$ users = get_users(array('fields'=> array('ID')));并替换$ user数组对象中的选择,但未显示。我只想吸引所有用户并加入下拉菜单。

我需要在下拉菜单中显示所有用户  screenshot of the customize theme

gzabocom 回答:在自定义主题中添加用户列表下拉列表

我找到了解决方案。我只是添加此钩子以数组格式获取用户  $ users = get_users();  $ user_names = wp_list_pluck($ users,'display_name');

,然后将“ choices”值更改为choices => $ user_names

本文链接:https://www.f2er.com/3023823.html

大家都在问