2013-06-29 70 views
0

這是Wordpress前端表單,用於人們選擇要提交的類別的類別 我的自定義分類標準是「位置」 但下面的代碼顯示了「listcat」的自定義分類標準我如何編輯它以顯示'位置'分類? 自定義分類標準的Wordpress前端

<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--> 

回答

0

找到這一行

$taxonomy = CUSTOM_CAT_TYPE; 

$taxonomy = 'location'; 

取代它可能有幫助,但不能肯定。

相關問題