2017-01-16 111 views
1

我一直在尝试编辑一个Wordpress模板以满足我的特定需求。问题是,默认情况下,人们只能从下拉列表中选择一个选项。我希望他们能够选择2个或更多。目前,这个功能已经在管理面板上,我可以选择多个值,但是从前端只能选择一个值。从下拉列表中选择多个,单个值传递

<div class="form-option"> 
    <label for="type"><?php _e('Usage', 'framework'); ?></label> 
    <span class="selectwrap"> 
     <select name="type" id="type" class="search-select"> 
      <option selected="selected" value="-1"><?php _e('Choose', 'framework'); ?></option> 
      <?php 
      /* Property Type */ 
      $property_types_terms = get_terms(
       array(
        "property-type" 
       ), 
       array(
        'orderby' => 'name', 
        'order'  => 'ASC', 
        'hide_empty' => false, 
        'parent'  => 0 
       ) 
      ); 
      generate_id_based_hirarchical_options("property-type", $property_types_terms, -1); 
      ?> 
     </select> 
    </span> 
</div> 

基于这段代码片段,任何人都可以给我一个提示什么可以做?我已经尝试向选择中添加多个,虽然这允许多个选择,但只有最后选择的选择会传递到数据库。

也许这个代码是问题吗?

// Attach Property Type with Newly Created Property 
      if(isset($_POST['type']) && ($_POST['type'] != "-1")) { 
       wp_set_object_terms($property_id, intval($_POST['type']), 'property-type'); 
      } 

任何帮助将不胜感激。

+0

'