We can easily show posts from single posts using this method.
But if we need to display posts from various post types, then we have to use a different method to do that.
Use the below code to display posts from multiple post types.
$args = array( 'post_type' => array( 'cats', 'dogs', 'rats'), //list of post types 'post_status' => 'publish' ); $the_query = new WP_Query( $args );
The above code creates an array and passes an array of all post types that we want to query for. Then we query WordPress using the defined set of parameters and it returns us all posts under this category.
For more info, check this.