Wordpress过滤器类别

时间:2013-05-19 08:59:25

标签: wordpress

如何获取所有子类别ID? Catrgories和subcatrgories就像

2013
   April 10
   April  9
   April  8 
   March  10
   March  9
2012
  June 10
  May 6
      May 5
Cast
Group
Party

如何获取当月的所有子类别ID? 我需要这个以分页来显示网页链接,例如site.com/catrgory/catrgory-slug/issue/{year}/{month}/ {day}。我需要显示与子类别页面的链接的分页。 列出特定子类别的所有帖子。

我正在使用重写网址

add_action('generate_rewrite_rules', 'past_issue_rewrite_rules');
function past_issue_rewrite_rules( $wp_rewrite ) {

    // handles paged/pagination requests
    $new_rules = array('category/catrgory-slug/issue/(.+)/(.+)/(.+)/' => '?year='.$wp_rewrite->preg_index(1).'&month='.$wp_rewrite->preg_index(2).'&day='.$wp_rewrite->preg_index(3));

    // Add the new rewrite rule into the top of the global rules array
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}

1 个答案:

答案 0 :(得分:0)

我厌倦了这个并且它正在运作

$root_categories = get_categories( array('parent' => 0,'hide_empty ' => 1, 'order' => 'desc'));
$categories = array();
if(empty($root_categories)){ return $categories;}
foreach($root_categories as $category){ 
    if(preg_match('/\d{4}$/',$category->name, $matches)) {
        $subcategories = get_categories('child_of='.$category->cat_ID.'&hide_empty=1&order=desc');
        if(!empty($subcategories)) {
            foreach($subcategories as $subcatgory) {
            }
        }
    }
}