WordPress Custom Post Type, List all Posts in a list
<?php
// Define the WP query
$args = array(
'post_type' => 'custom-post-type-name',//Swap in your CPT
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
if ($query->have_posts()) {
// Output the post titles in a list
echo '<ul id="cpt-menu">';
// Start the Loop
while ( $query->have_posts() ) : $query->the_post(); ?>
<li class="cpt-menu-item" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile;
echo '</ul>';
}
// Reset the WP Query
wp_reset_postdata();
?>