I have the following category structure:
Category x >> Category x Sub >> Category x Sub Sub
In my index.php
file, I have created links to category x
and so on.
So when the user clicks on the link in the main page, they go this page: wordpress/category/categoryx/
Only posts published under category x sub
should be displayed here, the problem is that in this page, posts published under category x sub sub
are also displayed.
In my archive.php
I used :
<?php while ( have_posts() ) : the_post(); if (in_category($cat)) { ?>
....
<?php } endwhile; ?>
this correctly hides the categoy x sub sub
posts in the main category but it also hides them from their own sub category.
So in this page:
wordpress/category/categoryx/category-x-sub/
the posts published under category x sub sub
are hidden too.