Sort posts by post_type in category.php template
Assuming your query does indeed have multiple post types, you’ll want to pluck them out before continuing (I assume you’re using $wp_query as your WP_Query object): <?php $all_post_types = array_map(function($item) { return $item->post_type; }, $wp_query->posts); // Now we get a unique list of post types: $unique_post_types = array_unique($all_post_types); // Use that unique list to drive … Read more