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


$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但它没有显示。我只想获取所有用户并放入下拉列表。

我需要在下拉列表中显示所有用户 自定义主题的屏幕截图

我找到了解决方案。我只是添加这个钩子来获取数组格式的用户 $users = get_users((; $user名称 = wp_list_pluck( $users,'display_name' (;

并将"选择"值更改为选择=> $user_名称

最新更新