get custom post type wordpress 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: wordpress get post type
get_post_type( int|WP_Post|null $post = null )
Example 3: get name custom post type wordpress
$pt = get_post_type_object( 'books' );
echo $pt->label;
echo $pt->labels->name;
echo $pt->labels->singular_name;