$listChurches
// WP_Query arguments $args = array( 'post_type' => array( 'church' ), 'posts_per_page' => '99', ); // The Query $listChurches = new WP_Query( $args ); // The Loop if ( $listChurches->have_posts() ) { while ( $listChurches->have_posts() ) { $listChurches->the_post(); // do something } } else { // no posts found } // Restore original Post Data wp_reset_postdata();