这是人们选择要提交列表的类别的 Wordpress 前端表单 我的自定义分类是“位置”,但下面的代码显示了“listcat”的自定义分类我如何编辑它以显示“位置”分类?
<div class="form_row">
<div class="label">
<label for="category"><?php echo CATEGORY; ?><span class="required">*</span></label>
</div>
<div class="field">
<div style="height:100px; width: 290px; overflow-y:scroll; margin-bottom: 15px;">
<?php
global $wpdb;
$taxonomy = CUSTOM_CAT_TYPE;
$table_prefix = $wpdb->prefix;
$wpcat_id = NULL;
//Fetch category
$wpcategories = (array) $wpdb->get_results("
SELECT * FROM {$table_prefix}terms, {$table_prefix}term_taxonomy
WHERE {$table_prefix}terms.term_id = {$table_prefix}term_taxonomy.term_id
AND {$table_prefix}term_taxonomy.taxonomy ='" . $taxonomy . "' and {$table_prefix}term_taxonomy.parent=0 ORDER BY {$table_prefix}terms.name ASC");
$wpcategories = array_values($wpcategories);
if ($wpcategories) {
echo "<ul class=\"select_cat\">";
if ($taxonomy == CUSTOM_CAT_TYPE) {
?>
<li><label><input type="checkbox" name="selectall" id="selectall" class="checkbox" onclick="displaychk_frm();" /></label><?php echo SLT_ALL; ?></li>
<?php
}
foreach ($wpcategories as $wpcat) {
$counter++;
$termid = $wpcat->term_id;
$name = $wpcat->name;
$termprice = $wpcat->term_price;
$tparent = $wpcat->parent;
?>
<li><label><input class="list_category" type="checkbox" name="category[]" id="<?php echo $termid; ?>" value="<?php echo $name; ?>" class="checkbox" /><?php echo $name; ?></label></li>
<?php
$args = array(
'type' => POST_TYPE,
'child_of' => $termid,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => CUSTOM_CAT_TYPE,
'pad_counts' => false);
$acb_cat = get_categories($args);
if ($acb_cat) {
echo "<ul class=\"children\">";
foreach ($acb_cat as $child_of) {
$term = get_term_by('id', $child_of->term_id, CUSTOM_CAT_TYPE);
$termid = $term->term_taxonomy_id;
$term_tax_id = $term->term_id;
$name = $term->name;
?>
<li><label><input class="list_category" type="checkbox" name="category[]" id="<?php echo $termid; ?>" value="<?php echo $name; ?>" class="checkbox" /><?php echo $name; ?></label></li>
<?php
$args = array(
'type' => POST_TYPE,
'child_of' => $term_tax_id,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => CUSTOM_CAT_TYPE,
'pad_counts' => false);
$acb_cat = get_categories($args);
if ($acb_cat) {
echo "<ul class=\"children\">";
foreach ($acb_cat as $child_of) {
$term = get_term_by('id', $child_of->term_id, CUSTOM_CAT_TYPE);
$termid = $term->term_taxonomy_id;
$term_tax_id = $term->term_id;
$name = $term->name;
?>
<li><label><input class="list_category" type="checkbox" name="category[]" id="<?php echo $termid; ?>" value="<?php echo $name; ?>" class="checkbox" /><?php echo $name; ?></label></li>
<?php
}
echo "</ul>";
}
}
echo "</ul>";
}
}
echo "</ul>";
}
?>
</div>
</div>
</div>
<!--End Row-->