Skip to content

Instantly share code, notes, and snippets.

@wycks
Created April 13, 2012 14:46
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Register Custom Post Type reference - WordPress
<?php
add_action( 'init', 'register_cpt_example' );
function register_cpt_example() {
//// Label parameters for the CPT admin
$labels = array(
'name' => _x( 'Examples', 'example' ),
'singular_name' => _x( 'Example', 'example' ),
'add_new' => _x( 'Add New Example', 'example' ),
'all_items' => _x( 'Examples', 'example' ),
'add_new_item' => _x( 'Add New Example', 'example' ),
'edit_item' => _x( 'Edit Example', 'example' ),
'new_item' => _x( 'New Example', 'example' ),
'view_item' => _x( 'View Example', 'example' ),
'search_items' => _x( 'Search Examples', 'example' ),
'not_found' => _x( 'No Examples found', 'example' ),
'not_found_in_trash' => _x( 'No Examples found in Trash', 'example' ),
'parent_item_colon' => _x( 'Parent Example:', 'example' ),
'menu_name' => _x( 'Examples', 'example' ),
);
//// The main parameters of the CPT function
$args = array(
'labels' => $labels,
'hierarchical' => true,
'description' => 'description',
'taxonomies' => array( 'category' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => '',
'show_in_nav_menus' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post',
'capabilities' => '',
'map_meta_cap' => 'false',
'register_meta_box_cb' => '',
'permalink_epmask' => 'EP_PERMALINK',
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt','custom-fields', 'trackbacks', 'comments', 'revisions', 'page-attributes', 'post-formats' ),
);
register_post_type( 'example', $args );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment