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');
}
任何幫助將不勝感激。
'