I think I have explained very bad. I'll try again
- Post Type: Video
- Custom post "video" with tag"space"
- Parent category: VideoPage (id=4)
- Children categories: A-B-C
I want show for Parent Category and children only custom post type "video" with tag "space"
In my file category.php I called the template:
<?php
// If is category or subcategory of $cat_id
if (!function_exists('is_category_or_sub')) {
function is_category_or_sub($cat_id = 4) {
foreach (get_the_category() as $cat) {
if ($cat_id == $cat->cat_ID || cat_is_ancestor_of($cat_id, $cat)) return true;
}
return false;
}
}
?>
<?php if (is_category_or_sub(4)) : ?>
<?php load_template(TEMPLATEPATH . '/cat_videopagine.php'); ?>
<?php else : ?>
Then in the file cat_videopagine.php I have this:
<?php
// The Query
$the_query = new WP_Query( 'post_type=video&tag=space' );
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
The Problem is:
Either in parent cat page or all children cat pages all same custom posts "video" with the tag "space"are displayed so I have
Parent: p1-p2-p3-p4-p5-p6
Cat A: p1-p2-p3-p4-p5-p6
Cat B: p1-p2-p3-p4-p5-p6
Cat C:p1-p2-p3-p4-p5-p6
There should be a function that calls the category and displays only the posts that belong to those category.
Cat A : p1(catA)
Cat B: p3(catB)