2013-03-20 21 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

相关问题