Created
January 2, 2014 19:39
-
-
Save bavington/8225249 to your computer and use it in GitHub Desktop.
Custom Post Type and initial taxonomy boilerplate
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 | |
/////////////////////////////////////////////// | |
////////// Projects Custom Post Type ////////// | |
/////////////////////////////////////////////// | |
add_action('init', 'register_projects'); | |
function register_projects() { | |
$labels = array( | |
'name' => _x('Projects', 'post type general name'), | |
'singular_name' => _x('Project', 'post type singular name'), | |
'add_new' => _x('Add New Project', 'Project item'), | |
'add_new_item' => __('Add New Project'), | |
'edit_item' => __('Edit Project'), | |
'new_item' => __('New Project'), | |
'all_items' => __( 'All Projects' ), | |
'view_item' => __('View Project'), | |
'search_items' => __('Search Projects'), | |
'not_found' => __('Nothing found'), | |
'not_found_in_trash' => __('Nothing found in Trash'), | |
'parent_item_colon' => '', | |
'menu_name' => 'Projects' | |
); | |
$args = array( | |
'labels' => $labels, | |
'description' => 'Holds our content managed projects', | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'query_var' => true, | |
'menu_icon' => 'dashicons-portfolio', | |
'rewrite' => true, | |
'capability_type' => 'post', | |
'hierarchical' => false, | |
'menu_position' => 5, | |
'supports' => array('title','editor','thumbnail'), | |
'has_archive' => true | |
); | |
register_post_type( 'projects' , $args ); | |
} | |
///////////////////////////////////////////////////////////////// | |
////////// Projects Custom Post Type Category Taxonomy ////////// | |
///////////////////////////////////////////////////////////////// | |
add_action( 'init', 'project_categories', 0 ); | |
function project_categories() { | |
$labels = array( | |
'name' => _x( 'Project Categories', 'taxonomy general name' ), | |
'singular_name' => _x( 'Projects Category', 'taxonomy singular name' ), | |
'search_items' => __( 'Search Project Categories' ), | |
'all_items' => __( 'All Project Categories' ), | |
'parent_item' => __( 'Parent Project Category' ), | |
'parent_item_colon' => __( 'Parent Project Category:' ), | |
'edit_item' => __( 'Edit Project Category' ), | |
'update_item' => __( 'Update Project Category' ), | |
'add_new_item' => __( 'Add New Project Category' ), | |
'new_item_name' => __( 'New Project Category' ), | |
'menu_name' => __( 'Project Categories' ), | |
); | |
$args = array( | |
'labels' => $labels, | |
'hierarchical' => true, | |
); | |
register_taxonomy( 'project_category', 'projects', $args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment