Identify category when get_posts pulls from parent
-
Hi, I have the following category structure: Reviews {empty parent} with children Game Review, Time Waster, and Book Review. I am using get_posts to pull the most recent posts from any of the children with the following code in a unique template:
<?php $args = array( 'posts_per_page' => 3, 'category' => 2 ); //the ID of Reviews. $reviews = get_posts( $args ); foreach ( $reviews as $post ) : setup_postdata( $post ); ?> {output title, abstract, etc.} <?php endforeach; wp_reset_postdata(); ?>And that all works fine. However, after this listing I would like to have a separate list in each individual child category offset by however many in that particular category showed up in the top-3 list. Unfortunately, whenever I try to find out the categories of each of the three posts using the_category, it always gives me ‘2’ the ID of the parent.
Is there an easier way to get the actual category of a post that were gotten with its parent category?
The topic ‘Identify category when get_posts pulls from parent’ is closed to new replies.