2013-03-20 18 views
0

嗨基本上我有一個頁面模板。就像目錄一樣。 我不想要一個插件,因爲我仍然想要控制代碼。WordPresspress:打印子類別職位包括(標題,固定鏈接和摘錄)在頁面模板內的類別

我只是想問,如果它可能?

==>目錄頁面(在類別六月號)

然後打印下的特定類別的所有子類別的相關信息。像這樣的格式:

=>子類別標題

then Posts Under (this) Subcategory 
-> Post Title including Permalink 
-> Post Excerpt 

-> Post Title including Permalink 
-> Post Excerpt 

-> Post Title including Permalink 
-> Post Excerpt 

=>子類別2標題

then Posts Under (this) Subcategory 
-> Post Title including Permalink 
-> Post Excerpt 

-> Post Title including Permalink 
-> Post Excerpt 

-> Post Title including Permalink 
-> Post Excerpt 

=>子類別3標題

then Posts Under (this) Subcategory 
-> Post Title including Permalink 
-> Post Excerpt 

-> Post Title including Permalink 
-> Post Excerpt 

-> Post Title including Permalink 
-> Post Excerpt 

等..

我ju st想知道wordpress是否有這種方法在特定的帖子類別下提取子類別。如何在模板中正確顯示它,就好像我要爲下一個問題創建另一個表格內容一樣。它會自動打印所有的子類別信息。請幫幫我。

感謝

+0

這絕對是,但你嘗試過什麼? – philipp 2013-03-20 16:11:38

+0

其實我不知道如何開始。我剛開始探討如何在特定類別下爆炸此類子類別。可能嗎? – topski 2013-03-20 16:14:03

回答

0

嘗試......未測試

<?php 

     $args = array(
      'type'      => 'post', 
      'child_of'     => 0, 
      'parent'     => '1', //Only get child categories 
      'orderby'     => 'name', 
      'order'     => 'ASC', 
      'hide_empty'    => 1, 
      'taxonomy'     => 'category', 
      'pad_counts'    => false 
     ); 

     $categoryList = get_categories($args); 

      if(!empty($categoryList)){ 

      foreach($categoryList as $category){ 

          $postArgs = array(
        'cat' => $category->id, 
          'post_type' => 'post' //Use other options as needed 
         );      

       query_posts($postArgs); 

         while (have_posts()) : the_post(); 
       echo get_the_title(); 
       echo get_permalink(); 
         echo get_the_excerpt(); 
       endwhile; 

      } 

      } 
    ?> 
+0

嗨,謝謝,但是工作:( – topski 2013-03-20 16:47:13

+0

你得到什麼錯誤? – 2013-03-20 17:00:14

+0

沒有錯誤,但沒有顯示在頁面中 – topski 2013-03-20 17:14:26

相關問題