display custom post type category code example
Example 1: create custom post type with category in wordpress functions.php
function create_posttype() {
register_post_type( 'wpll_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'products'),
)
);
}
add_action( 'init', 'create_posttype' );
Example 2: display custom post type
$args = array(
'post_status' => 'publish',
'posts_per_page' => 5,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
the_excerpt();
endwhile;