Custom Post Type Archive Loop

Replace ‘name’ with the appropriate custom post type slug to query only those posts.  Since the args are in an array, multiple post type slugs can be used.  Multiple post type archives can be created from one template file with if/else statements.

Place in template file.

$args = array( 'post_type' => 'name' );
    $name = new WP_Query($args);                    
    while ( $name->have_posts() ) : $name->the_post(); 

        <h3 class="postTitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>

    <?php endwhile; ?>


Dave Winter focuses in WordPress UI Design and WordPress Plugin Development (some have labelled him a fanatic) but has hands in many other projects, including photography and music. He's never far from a computer... or an iPad (for testing purposes, of course). If you've been to a WordCamp in Southern California, he probably already knows who you are (or maybe not - he's terrible with names). Dave currently teaches courses at California State University, Long Beach alongside his small business at (and his students think he's pretty boss).
© 2008-2020,