forgot to say… when i write a new post, in category field it shows correctly with principles of economics and all the other child categories inside books. But when editing a post it shows all the child categories of books as if they were a parent category.
Hi people! I finally solve this problem.
The get_the_category() function returns the categories ordered by category name. I used the following code:
<?php
$category = get_the_category();
foreach($category as $cat) {
if($cat->category_parent == 0) {
if($cat->cat_ID == 28) { // Books category ID
include(TEMPLATEPATH . '/sidebar_livros.php');
} else {
get_sidebar();
}
}
}
?>