Skip to content

Instantly share code, notes, and snippets.

@ashby
Created May 1, 2014 00:30
Show Gist options
  • Select an option

  • Save ashby/11442085 to your computer and use it in GitHub Desktop.

Select an option

Save ashby/11442085 to your computer and use it in GitHub Desktop.
WP: Custom Post Type
add_action( 'init', 'register_my_cpt' );
function register_my_cpt() {
$labels = array(
'name' => _x( 'Custom', 'my_cpt' ),
'singular_name' => _x( 'Custom', 'my_cpt' ),
'add_new' => _x( 'Add New', 'my_cpt' ),
'add_new_item' => _x( 'Add New Custom', 'my_cpt' ),
'edit_item' => _x( 'Edit Custom', 'my_cpt' ),
'new_item' => _x( 'New Custom', 'my_cpt' ),
'view_item' => _x( 'View Custom', 'my_cpt' ),
'search_items' => _x( 'Search Customs', 'my_cpt' ),
'not_found' => _x( 'No customs found', 'my_cpt' ),
'not_found_in_trash' => _x( 'No customs found in Trash', 'my_cpt' ),
'parent_item_colon' => _x( 'Parent Custom:', 'my_cpt' ),
'menu_name' => _x( 'Custom', 'my_cpt' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'menu_icon' => '',
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'my_cpt', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment