Last Updated: February 25, 2016
·
466
· elfleat

Wordpress Query for Custom Post Types

<?php

$postTypeToQuery = "examplemovies";

$args = array( 'post_type' => $postTypeToQuery, 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>

    <div class="post">
       <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h2>

       <?php the_content(); ?>

    </div>
<?php
endwhile;

?>