0

我似乎无法在我正在处理的那个小部件上进行多项选择。基本上我有这样的事情:

 function form( $instance ) {
    $team_args = array(
    'post_type' => 'team-post',
    'posts_per_page' => -1
    );
    $team_members = array();
    $the_query = new WP_Query($team_args);
    while ($the_query->have_posts()){
        $the_query->the_post();
        global $post;
        $team_members['person_name'][] = the_title('','',false); 
        $team_members['description'][] = $post->post_content; 
        $image = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ));
        $team_members['person_image'][] = $image[0];
    }?>
     <select class="widefat" id="<?php echo $this->get_field_id('person'); ?>" name="<?php echo $this->get_field_name('person'); ?>" multiple>
    <?php foreach($team_members['person_name'] as $person){ ?>
     <option value="<?php echo esc_attr($person) ?>" <?php selected($person, $team_members['person_name']) ?>><?php echo $person; ?></option>
    <?php } ?>
    </select>
    <?php        
}

但它不起作用,我不知道。

4

0 回答 0