Hello Kafkaesqui,
Ops! there is a detail I forgot to mention. The article “This is an apple’s article” was assigned to three different categories, which belong to parent cats. I’m very, very sorry for this critical omission:
Parent-1 (ID=4)
— Fruit (ID=16)
Parent-2 (ID=3)
— Vegetables (ID=18)
Parent-3 (ID=5)
— Plants (ID=17)
In this order I had the modification in this way:
<?php query_posts('cat=16'); ?> // Fruit
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_category() ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
</div>
<?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
<?php endif; ?>
However, results are same as before. Query_posts certainly limit posts of a specific category, but multiple cat names continue appearing above the title.
Until this moment, the nearest result was give get_the_category tag with this string:
<?php
$category = get_the_category();
echo $category[0]->cat_name;
?>
This shows only one cat as I need, but limited to array[0], it’s a shame:
Vegetables
This is an apple’s article
Fruit
This is an orange’s article
Fruit
This is a watermelon’s article
The right way is to show “Vegetables” in each cat, but it don’t works. Also I proved with various conditional tags ways without success.