2017-07-30 123 views
1

我有以下的在我的WordPress的模板,我想改變它的碼位,所以它只顯示頂級類別,而不是所有類別:顯示頂級的wordpress類別

<?php 
/** 
* Generate list of EDD categories to browse 
*/ 

if ($categories) { ?> 

    <div class="search-cats"> 
     <div class="search-cat-text"> 
      <?php _e('Or browse by category: ', 'checkout'); ?> 
     </div> 
     <nav> 
     <?php 
      /** 
      * Generate list of EDD category links 
      */ 
      foreach ($categories as $category) { 
       $link = get_term_link($category, 'download_category'); 


       echo '<a href="' . esc_url($link) . '" rel="tag">' . $category->name . '</a>'; 
      } 
     ?> 
     </nav> 
    </div> 
<?php } ?> 

燦誰來幫幫我?

回答

2

點是父=> 0

<?php 
    /** 
    * Generate list of EDD categories to browse 
    */ 
    $args = array(
     'orderby' => 'name', 
     'taxonomy' => 'download_category', 
     'hide_empty' => 0, 
     'parent' => 0 
    );  
    $categories = get_categories($args); 
+0

謝謝,完美的作品。 – Teege