Last active
August 29, 2015 14:08
-
-
Save schikulski/6cf4e33d87949146694e to your computer and use it in GitHub Desktop.
Post types template for Wordpress
This file contains 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_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