Title: Multiple post types in one query loop?
Last modified: December 7, 2023

---

# Multiple post types in one query loop?

 *  [ThePilot](https://wordpress.org/support/users/thepilot/)
 * (@thepilot)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/multiple-post-types-in-one-query-loop/)
 * Hello everyone! I have multiple custom post types that I’d like to include in
   one query loop. However, the current Query Loop block doesn’t have the option
   to include more than one. It’s either post OR page OR custom post type.
 * Is it possible to include more than one post type? For instance, post AND page
   AND custom post type.
 * Thank you for your help!
 * Al

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Samedi S. Amba](https://wordpress.org/support/users/skyoyugi/)
 * (@skyoyugi)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/multiple-post-types-in-one-query-loop/#post-17259839)
 * Hello [@thepilot](https://wordpress.org/support/users/thepilot/),
 * So sorry for the challenge. Let me use code to explain what you can do.
 * Assuming you have two post types: testimonial and post. What you need to do is
   to add an array that will loop through these post types. Here’s some sample code,
   then I’ll explain:
 *     ```wp-block-code
       <?php
       // Code starts here. Calls the post types (2 in this case)
       $args = array(
           'post_type'      => array( 'testimonial', 'post' ),
           'posts_per_page' => 1,
       );
   
       $query = new WP_Query( $args );
   
       $postcount = 0;
                   ?>
                   <?php if ($query->have_posts()) : ?>
                       <?php while ($query->have_posts()) : $query->the_post(); ?>
                           <?php $postcount++; ?>
       //looped content here
       <?php wp_reset_query(); ?>
       ```
   
 * The first part of the code pulls the array of post types to be presented. (**
   testimonial **and **post** in this case)
 * The second part then loops through and presents the content, if any.
 * Hope that helps! And do let me know if you’ll need further help.
 *  Thread Starter [ThePilot](https://wordpress.org/support/users/thepilot/)
 * (@thepilot)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/multiple-post-types-in-one-query-loop/#post-17260308)
 * Thank you very much [@skyoyugi](https://wordpress.org/support/users/skyoyugi/)!
 * Where would I paste this code exactly? In the functions.php file? Actually I’d
   like to use the Query Loop block, because it’s easier to style with the block
   editor. Is this how it will work?
 * Thank you so much for your help,
 * Al
 *  Thread Starter [ThePilot](https://wordpress.org/support/users/thepilot/)
 * (@thepilot)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/multiple-post-types-in-one-query-loop/#post-17452883)
 * Hey [@skyoyugi](https://wordpress.org/support/users/skyoyugi/), sorry for asking
   again… Is this possible to do with the query loop *block* ? Ask that block to
   display more than one post type? Thank you very much for your help
 *  [jnz31](https://wordpress.org/support/users/jnz31/)
 * (@jnz31)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/multiple-post-types-in-one-query-loop/#post-17941607)
 * the way i see it, this is not possible, as the request goes through the rest 
   api, and there you cannot query for multiple posts at once (‘/wp-json/wp/v2/post-
   type/’).
 * you would need to code your own block.
 * another hacky solution would be, to overwrite the output of your block via `add_filter('
   render_block_core/query', 'support_render_core_query', 10, 3);` and then write
   your own wp_query and manipulate the output of the mentioned filter. this is 
   hacky, since you woudnt see the result in the block editor, only in the frontend.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Multiple post types in one query loop?’ is closed to new replies.

## Tags

 * [query loop](https://wordpress.org/support/topic-tag/query-loop/)

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 4 replies
 * 3 participants
 * Last reply from: [jnz31](https://wordpress.org/support/users/jnz31/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/multiple-post-types-in-one-query-loop/#post-17941607)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
