Wordpress Metabox填充从数组中选择

时间:2017-02-08 14:00:32

标签: php wordpress

我试图用数组中的注册用户(贡献者)填充选择,以便在前端使用它,但出于某种原因,我无法完成它。
这是我的代码:

$user_query = new WP_User_Query(array('role' => 'Contributor'));

if (!empty($user_query->results))
{
    $index = 0;
    $contributors = array();
    foreach ($user_query->results as $user)
    {
        $contributors[$index] = $user->ID;
        $index++;
    }
}

array(
    'name' => esc_html__('Select', 'your-prefix'),
    'id' => "{$prefix}tecnico",
    'type' => 'select',
    // Array of 'value' => 'Label' pairs for select box
    'options' => $contributors,
    // Select multiple values, optional. Default is false.
    'multiple' => false,
    'std' => 'value2',
    'placeholder' => esc_html__('Select an Item', 'your-prefix'),
),

0 个答案:

没有答案