Hello @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:
<?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.
Thank you very much @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
Hey @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
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.