0
我想能夠列出瀏覽父類別時的所有帖子(子女和父母)。WordPress的 - 在父類別中列出所有類別的子帖子
像這樣:
- 父(從兒童1兒童2顯示帖子)
- 兒童1(顯示自兒童1只職位)
- 兒童2(顯示自獨生子女帖子2)
有了下面這段代碼(放在category.php)我不明白人l當我在父類別中時的帖子。我只是從一個孩子類別而不是幾個類別發佈帖子。
任何想法如何解決這個問題?
<?php get_header(); ?>
<div class="container">
<div class="row">
<?php get_template_part('include-cat-tag'); ?>
<div class="col-xs-12 col-sm-9 col-md-9 list-page-middle">
<header class="clearfix">
<h1><?php single_cat_title('', true); ?></h1>
</header>
<?php
wp_reset_query();
$categories = get_the_category();
$category_id = $categories[0]->cat_ID;
$args = array(
'posts_per_page' => 100,
'category__in' => array($category_id),
'orderby' => 'meta_value title',
'order' => 'ASC',
'post_status' => 'publish',
'meta_key' => 'betyg',
'child_of' => $category_id
);
query_posts($args);
if (have_posts()): while (have_posts()) : the_post();
get_template_part('include-list-post');
?>
<?php endwhile; ?>
<?php else: ?>
<?php get_template_part('include-no-post'); ?>
<?php endif; ?>
</div>
</div>
<?php
get_template_part('include-list');
get_template_part('include-social');
?>
</div>
</div>
<?php get_footer(); ?>