Creating custom Post Type In WordPress

WordPress big advantage while comparing with other CMS is Custom Post type mechanism.
Custom post type allows to create large variety of content.
Lets have a look at how to create a custom post type
Custom post types are available from WordPress 2.9.
Custom post type is nothing more than a regular post.
You could create custom post types for books, movies, reviews, Books and so on.

Creating custom post type

To create custom Post type we have a plenty of plugins but we can achieve this by simple script.
Lets create a custom post type for books.
Below is the script for creating custom post type.

function Books() {
$labels = array(
'name' => _x( 'Books', 'post type general name' ),
'singular_name' => _x( 'Book', 'post type singular name' ),

'add_new' => _x( 'Add New', 'book' ),

'add_new_item' => __( 'Add New Book' ),

'edit_item' => __( 'Edit Book' ),

'new_item' => __( 'New Book' ),

'all_items' => __( 'All Books' ),

'view_item' => __( 'View Book' ),

'search_items' => __( 'Search Books' ),

'not_found' => __( 'No Books found' ),

'not_found_in_trash' => __( 'No Books found in the Trash' ),

'parent_item_colon' => '',

'menu_name' => 'Books'


$args = array(

'labels' => $labels,

'description' => 'Holds our Books and Book specific data',

'public' => true,

'menu_position' => 5,

'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),

'has_archive' => true,


register_post_type( 'Book', $args );


add_action( 'init', 'Books' );

Now lets’s discuss about the parameters
Label Option is an array for different labels for our custom post type

A small explanation about the custom Post type.


All to do with Visibiity


To define the position of the custom post type in admin menu.


to get default WordPress controls in edit sections


To create the URL rewrite


You Might Also Like