WordPress Custom Post Type Code Generator

Default Post Types

There are five post types that are readily available to users
or internally used by the WordPress installation by default :
Post (Post Type: 'post')
Page (Post Type: 'page')
Attachment (Post Type: 'attachment')
Revision (Post Type: 'revision')
Navigation menu (Post Type: 'nav_menu_item')

Post

Post in WordPress is a post type that is typical for and most used by blogs.
Posts are normally displayed in a blog in reverse sequential order 
by time (newest posts first). Posts are also used for creating the feeds.

Page

Page in WordPress is like post, but it lives outside the normal time-based

listings of posts. Pages can use different page templates to display them. 
Pages can also be organized in a hierarchical structure, with pages being 
parents to other pages, but they normally cannot be assigned 
categories and tags.If permalinks are enabled, the permalink of a page
is always composed solely of the main site URL and the user-friendly 
and URL-valid names (also referred to as slug) of the page and
its parents if they exist. See the Pages article for more information
about the differences.

Copy and paste the following code into your functions.php file

add_action( 'init', 'register_cpt_book' );

function register_cpt_book() {

    $labels = array( 
        'name' => _x( 'Books', 'book' ),
        'singular_name' => _x( 'Book', 'book' ),
        'add_new' => _x( 'Review', 'book' ),
        'add_new_item' => _x( 'wolf of street', 'book' ),
        'edit_item' => _x( 'Edit Book', 'book' ),
        'new_item' => _x( 'New Book', 'book' ),
        'view_item' => _x( 'View Book', 'book' ),
        'search_items' => _x( 'Search Books', 'book' ),
        'not_found' => _x( 'No books found', 'book' ),
        'not_found_in_trash' => _x( 'No books found in Trash', 'book' ),
        'parent_item_colon' => _x( 'Parent Book:', 'book' ),
        'menu_name' => _x( 'Books', 'book' ),
    );

    $args = array( 
        'labels' => $labels,
        'hierarchical' => true,

        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'custom-fields', 'comments', 'page-attributes' ),
        'taxonomies' => array( 'category', 'post_tag', 'page-category' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,

        'show_in_nav_menus' => false,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
    );

    register_post_type( 'book', $args );
}

For more information create custom plugin click here

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s