https://secondlinethemes.com/display-custom-post-types-wordpress/
https://developer.wordpress.org/reference/functions/wp_reset_postdata/
参考代码:
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role=“main”>
<?php if (have_posts()) : ?>
<?php while (have_posts() : the_post());
// This is the main WordPress loop which loads the default “blog” posts. As an example, we will display only the article’s title.
echo the_title();
endwhile; ?>
<?php endif; ?>
---------------
// Display Podcasts CPT
<?php
$args = array(‘post_type’ => ‘podcasts’, ‘posts_per_page’ => ‘3’);
$myQuery = new WP_Query($args);
?>
<?php if ($myQuery->have_posts() : ?>
<?php while ($myQuery->have_posts() : $myQuery->the_post(); ?>
<?php // Dislpay the podcast title
echo the_title(); ?>
<?php endwhile; wp_reset_postdata(); ?>
<?php endif; ?>
</main>
</div>
------------
显示有哪些内容类型: https://developer.wordpress.org/?s=post+type