Last active
February 13, 2016 19:49
-
-
Save twentyfortysix/e0eb15d61f56d34dcc9e to your computer and use it in GitHub Desktop.
WP - register post type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'register_my_post_type' ); | |
/** | |
* Register a type post type. | |
* | |
* @link http://codex.wordpress.org/Function_Reference/register_post_type | |
*/ | |
function register_my_post_type() { | |
$labels = array( | |
'name' => _x( 'types', 'post type general name', 'your-plugin-textdomain' ), | |
'singular_name' => _x( 'type', 'post type singular name', 'your-plugin-textdomain' ), | |
'menu_name' => _x( 'types', 'admin menu', 'your-plugin-textdomain' ), | |
'name_admin_bar' => _x( 'type', 'add new on admin bar', 'your-plugin-textdomain' ), | |
'add_new' => _x( 'Add New', 'type', 'your-plugin-textdomain' ), | |
'add_new_item' => __( 'Add New type', 'your-plugin-textdomain' ), | |
'new_item' => __( 'New type', 'your-plugin-textdomain' ), | |
'edit_item' => __( 'Edit type', 'your-plugin-textdomain' ), | |
'view_item' => __( 'View type', 'your-plugin-textdomain' ), | |
'all_items' => __( 'All types', 'your-plugin-textdomain' ), | |
'search_items' => __( 'Search types', 'your-plugin-textdomain' ), | |
'parent_item_colon' => __( 'Parent types:', 'your-plugin-textdomain' ), | |
'not_found' => __( 'No types found.', 'your-plugin-textdomain' ), | |
'not_found_in_trash' => __( 'No types found in Trash.', 'your-plugin-textdomain' ) | |
); | |
$args = array( | |
'labels' => $labels, | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'type' ), | |
'capability_type' => 'post', | |
'has_archive' => true, | |
'hierarchical' => false, | |
'menu_position' => null, | |
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) | |
); | |
register_post_type( 'type', $args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment