I want to be able to list ALL posts (children and parent) when browsing a parent category.
Like this:
- Parent (Show posts from Child 1 and Child 2)
- Child 1 (Show only posts from Child 1)
- Child 2 (Show only posts from Child 2)
With this code below (placed in category.php) I don't get all the posts when I'm in a parent category. I just get posts from ONE child category instead of several.
Any ideas how to solve this?
<?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(); ?>