Wordpress小部件多选

时间:2013-10-15 09:30:35

标签: wordpress widget

我似乎在获取多个选项以处理我正在处理的小部件时遇到问题。基本上我有这样的事情:

 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        
}

但它没有用,我也不知道。

0 个答案:

没有答案