WPGenerate.me - Custom Post Type

Use the form fields below to generate a Custom Post Type function to easily add to your next site.

Singular Name:
Plural Name:
Post Type Key:
Description:

Hierarchical:
Exclude From Search:
Has Archive:
Can Export:

Supported Features


Taxonomies

 
Menu Position
Menu Icon

Permalink Rewrite
Custom Query:

// Register Custom Post Type  
function custom_post_type() {  

 $labels = array(
  'name'                => __('Post Types', 'Post Type General Name'),
  'singular_name'       => __('Post Type', 'Post Type Singular Name'),
  'menu_name'           => __('Post Type'),
  'parent_item_colon'   => __('Parent Item:'),
  'all_items'           => __('All Items'),
  'view_item'           => __('View Item'),
  'add_new_item'        => __('Add New Item'),
  'add_new'             => __('Add New'),
  'edit_item'           => __('Edit Item'),
  'update_item'         => __('Update Item'),
  'search_items'        => __('Search Item'),
  'not_found'           => __('Not found'),
  'not_found_in_trash'  => __('Not found in Trash'),  
 );  
 
 $capabilities = array(
  'edit_post'           => 'edit_post',
  'read_post'           => 'read_post',
  'delete_post'         => 'delete_post',
  'edit_posts'          => 'edit_posts',
  'edit_others_posts'   => 'edit_others_posts',
  'publish_posts'       => 'publish_posts',
  'read_private_posts'  => 'read_private_posts',
 );
 
 $args = array(
  'label'               => __('post_type'),
  'description'         => __(''),
  'labels'              => $labels,
  'supports'            => array('title', ),
  'taxonomies'          => array( ),
  'hierarchical'        => false,
  'public'              => true,
  'show_ui'             => true,
  'show_in_menu'        => true,
  'show_in_nav_menus'   => true,
  'show_in_admin_bar'   => false,
  'menu_position'       => 5,
  'menu_icon'           => '',
  'can_export'          => false,
  'has_archive'         => true,
  'rewrite'             => true,
  'exclude_from_search' => false,
  'publicly_queryable'  => true,
  'query_var'           => 'post_type',
  'capability_type'     => 'post',  	
 );  

 register_post_type( 'post_type' , $args );  
}  

add_action( 'init' , 'custom_post_type' , 0 );