Create custom post type in WordPress

WordPress is not only for just blogging but it is widely used for more than a blog. So the custom post type is widely used for display different kind of contents. WordPress has two main post types which is posts and pages. Posts is mainly used for blog like structure it is very useful to display posts order by date. Custom post type is not very different from the other posts but its usage is different. So all the WordPress developers should know about the custm post type creation. This is very simple process to create custom post type in WordPress.You just need to add some codes on function.php file and you can use it like as other posts.

Please Put below code in function.php file

//custom post type for Our Team
function themename_custom_post_team() {
	$labels = array(
		'name'               => __( 'Team' ),
		'singular_name'      => __( 'Team' ),
		'add_new'            => __( 'Add New' ),
		'add_new_item'       => __( 'Add New Team' ),
		'edit_item'          => __( 'Edit Team' ),
		'new_item'           => __( 'New Team Member' ),
		'all_items'          => __( 'All Team Members' ),
		'view_item'          => __( 'View Our Team' ),
		'search_items'       => __( 'Search Team' ),
		'not_found'          => __( 'No Member found' ),
		'not_found_in_trash' => __( 'No Member found in the Trash' ), 
		'parent_item_colon'  => '',
		'menu_name'          => 'Our Team'
	);
	$args = array(
		'labels'        => $labels,
		'description'   => 'Manage Team',
		'public'        => true,
		'menu_position' => 20,
		'supports'      => array('title','thumbnail', 'excerpt', 'editor'),
		'has_archive'   => true,
	);
	register_post_type( 'team', $args );	
}
add_action( 'init', 'themename_custom_post_team' );

// texonomy for custom post type
function team_taxonomy() {  
	register_taxonomy(  
		'team_category',  
		'team',
		array(  
			'hierarchical' => true,  
			'label' => 'Category',  
			'query_var' => true,  
			'rewrite' => array('slug' => 'team-category')  
		)  
	);  
}  
add_action( 'init', 'team_taxonomy' );

After adding this code to your function.php file you will see at the backend the new post type called Our Team in WordPress Menu. Your custom post type is ready to use in the backend now the above code will display as follows in the backend. see the screenshot below.

custom-post-type

This is very simple and best way to add custom post type in WordPress. You can use custom post type by using wp_query_posts() before loop.



Custom Post type by Plugin

If you are not well versed with the coding and you need somethings very fast then you can use the custom post types plugin. This plugin helps you to create custom post type and texonomies in WordPress.

Custom Post Type UI

custom-post-type-plugin

Hope this article may useful for you and you can learn lots from this your comments and queries can makes us to serve you better.
Thanks for reading.

9 thoughts on “Create custom post type in WordPress”

  1. 2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    //custom post type for Our Team
    function themename_custom_post_team() {
    $labels = array(
    ‘name’ => __( ‘Team’ ),
    ‘singular_name’ => __( ‘Team’ ),
    ‘add_new’ => __( ‘Add New’ ),
    ‘add_new_item’ => __( ‘Add New Team’ ),
    ‘edit_item’ => __( ‘Edit Team’ ),
    ‘new_item’ => __( ‘New Team Member’ ),
    ‘all_items’ => __( ‘All Team Members’ ),
    ‘view_item’ => __( ‘View Our Team’ ),
    ‘search_items’ => __( ‘Search Team’ ),
    ‘not_found’ => __( ‘No Member found’ ),
    ‘not_found_in_trash’ => __( ‘No Member found in the Trash’ ),
    ‘parent_item_colon’ => ”,
    ‘menu_name’ => ‘Our Team’
    );
    $args = array(
    ‘labels’ => $labels,
    ‘description’ => ‘Manage Team’,
    ‘public’ => true,
    ‘menu_position’ => 20,
    ‘supports’ => array(‘title’,’thumbnail’, ‘excerpt’, ‘editor’),
    ‘has_archive’ => true,
    );
    register_post_type( ‘team’, $args );
    }
    add_action( ‘init’, ‘themename_custom_post_team’ );

    // texonomy for custom post type
    function team_taxonomy() {
    register_taxonomy(
    ‘team_category’,
    ‘team’,
    array(
    ‘hierarchical’ => true,
    ‘label’ => ‘Category’,
    ‘query_var’ => true,
    ‘rewrite’ => array(‘slug’ => ‘team-category’)
    )
    );
    }
    add_action( ‘init’, ‘team_taxonomy’ );

  2. This is such a great resource that me are providing and you give it away for free. seeing that understand the value of providing a quality resource for free

  3. Wow. cool post. I’d like to write like this too – taking time and real hard work to make a great article…

  4. This is great! You always simplify everything as much as possible which is awesome! Wish this article was about a few months back when I was proper confused on this subject.

  5. Thanks for the information your article brings. I see the novelty of your writing, I will share it for everyone to read together. I look forward to reading many articles from you.

  6. by visiting this site I found cool stuff here keep it up.

  7. WordPress is not only for just blogging but it is widely used for more than a blog.

  8. thank you for sharing information

Leave a Reply