I need that each category of WordPress will display only its own posts and not those of its child categories. How is this done?
I need posts that are in sub-categories to appear only in their sub-categories and not to appear in the parent category (where I want to see only posts that were marked for that parent category.
However, in the parent category I get all posts that are marked to appear in the sub-category of that parent category.
For example, if I have category “cars” and underneath it, subcategories “Fiat”, Ford”, “Honda”, I see the Fiat posts both in the subcategory “Fiat” and in the parent category “Cars”.
How can we fix that?
Make use of the
parse_tax_query
action to exclude children of the current categoryYou can try something like this: (Requires php 5.3 +)
Works only with WordPress >= 3.3.
In your functions.php theme file: