0

For the last two days I tried to loop through a parent category and display my custom post type posts within it.

I've created a custom post type with the name: mentors_post_type and participants_post_type, where I use category as a taxonomy.

'taxonomies' => array( 'category', 'post_tag' ),

Both post types are organized in categories for each year: 2016, 2017, 2018, etc. Somehow I can't achieve to loop through the years category and display the posts and sub-categories like:

(year category)
2017 (subcategory)
all posts with custom post type: mentors_post_type 
2016 (subcategory)
all posts with custom post type: mentors_post_type 

No matter how I've tried it, I don't get any posts from the custom post type or all posts from the custom post type (can't filter them by category). When I just get the category names and their post-counts, the post-counts are right.

1

1 Answer 1

-1

You would do something along these lines using the category id, and an array of the post_types within your loop

query_posts( array(
 'post_type' => array( 'post', 'report', 'opinion', bookmark' ),
 'cat' => 3,
 'orderby' => 'date',
 'order' => 'DESC',
 'showposts' => 5 )
 );

Hope that helps

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.