How to get custom post type in WordPress 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: get name custom post type wordpress
$pt = get_post_type_object( 'books' );
echo $pt->label;
echo $pt->labels->name;
echo $pt->labels->singular_name;