Online Forum To Support Coders With Technical Assistance - Read Write Execute

How to add new custom post type in wordpress

Ankit Agrawal
Ankit Agrawal
Published on August 11, 2015 · 1 min read

add below code in your theme function file

add_action( 'init', 'my_custom_post_type' );

function my_custom_post_type() {
  register_post_type( 'custom_post_type',
    array(
      'labels' => array(
        'name' => __( 'Custom Post Type' ),
        'singular_name' => __( 'Custom Post Type' )
      ),
      'public' => true,
      'has_archive' => true,
	  'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' )
    )
  );
}
Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article How to remove outer ul and div from WordPress menu Next Article → How to add new sidebar for my theme in wordpress