Custom Post Type

Published May 3, 2016 by Anil Kumar Vishwakarma

Custom Post type creation by using existing theme Functions.php file

add_action( 'init', 'rv_invoice_cpt' );
function rv_invoice_cpt() {
 $labels = array(
 'name' => _x( 'Invoice', 'post type general name', 'engwp' ),
 'singular_name' => _x( 'Invoice', 'post type singular name', 'engwp' ),
 'menu_name' => _x( 'Invoices', 'admin menu', 'engwp' ),
 'name_admin_bar' => _x( 'Invoice', 'add new on admin bar', 'engwp' ),
 'add_new' => _x( 'Add New', 'Invoice', 'engwp' ),
 'add_new_item' => __( 'Add New Invoice', 'engwp' ),
 'new_item' => __( 'New Invoice', 'engwp' ),
 'edit_item' => __( 'Edit Invoice', 'engwp' ),
 'view_item' => __( 'View Invoice', 'engwp' ),
 'all_items' => __( 'All Invoices', 'engwp' ),
 'search_items' => __( 'Search Invoices', 'engwp' ),
 'parent_item_colon' => __( 'Parent Invoice:', 'engwp' ),
 'not_found' => __( 'No Invoices found.', 'engwp' ),
 'not_found_in_trash' => __( 'No Invoices found in Trash.', 'engwp' )
 );
 $args = array(
 'description' => __( 'Invoice', 'engwp' ),
 'labels' => $labels,
 'supports' => array( 'title' ),
 'hierarchical' => false,
 'public' => true,
 'publicly_queryable' => true,
 'query_var' => true,
 'rewrite' => array( 'slug' => 'invoice' ),
 'show_ui' => true,
 'menu_icon' => 'dashicons-media-spreadsheet',
 'show_in_menu' => true,
 'show_in_nav_menus' => false,
 'show_in_admin_bar' => true,
 // 'menu_position' => 5,
 'can_export' => true,
 'has_archive' => false,
 'exclude_from_search' => true,
 'capability_type' => 'post',
 );
 register_post_type( 'invoice', $args );
}
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

%d bloggers like this: