wordpress get custom post type in loop code example
Example 1: wp_query get custom post type
<?php
$args = array(
'post_type' => 'custom_type',
'post_status' => 'publish',
'posts_per_page' => 8,
'orderby' => 'title',
'order' => 'ASC',
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
print the_title();
the_excerpt();
endwhile;
wp_reset_postdata();
?>
Example 2: wp loop custom post type
<?php
$loop = new WP_Query(
array(
'post_type' => 'yourposttypehere'
'posts_per_page' => 50
)
);
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="col-sm-4">
My column content
</div>
<?php endwhile;
wp_reset_postdata();
?>