Created
February 1, 2016 09:29
-
-
Save AaronRutley/901ae2fba4e00673dee5 to your computer and use it in GitHub Desktop.
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 // Function Partial : Custom Post Types | |
add_action('init', 'turbo_custom_post_types'); | |
// Register Custom Post Type | |
function turbo_custom_post_types() { | |
$types = array( | |
array( | |
'the_type' => 'work', | |
'single' => 'Work Item', | |
'plural' => 'Work Items', | |
'icon' => 'dashicons-media-document' | |
) | |
); | |
foreach ($types as $type) { | |
$the_type = $type['the_type']; | |
$single = $type['single']; | |
$plural = $type['plural']; | |
$icon = $type['icon']; | |
$labels = array( | |
'name' => _x($plural, 'post type general name'), | |
'singulturbo_name' => _x($single, 'post type singular name'), | |
'add_new' => _x('Add New', $single), | |
'add_new_item' => __('Add New '. $single), | |
'edit_item' => __('Edit '.$single), | |
'new_item' => __('New '.$single), | |
'view_item' => __('View '.$single), | |
'search_items' => __('Search '.$plural), | |
'not_found' => __('No '.$plural.' found'), | |
'not_found_in_trash' => __('No '.$plural.' found in Trash'), | |
'parent_item_colon' => '' | |
); | |
$args = array( | |
'labels' => $labels, | |
'public' => true, | |
'has_archive' => false, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'query_var' => true, | |
'rewrite' => true, | |
'capability_type' => 'post', | |
'hierarchical' => true, | |
'menu_position' => 20, | |
'show_in_menu' => true, | |
'menu_icon' => $icon, | |
'show_in_nav_menus' => true, | |
'supports' => array('title','editor', 'author', 'custom-fields') | |
); | |
register_post_type($the_type, $args); | |
} | |
} | |
// create two taxonomies, genres and writers for the post type "book" | |
function create_custom_taxonomies() { | |
$customtaxs = array( | |
array( | |
'tag_slug' => 'work-category', | |
'tag_single' => 'Work Category', | |
'tag_plural' => 'Work Categories' | |
) | |
); | |
foreach ($customtaxs as $customtax) { | |
$tag_slug = $customtax['tag_slug']; | |
$tag_single = $customtax['tag_single']; | |
$tag_plural = $customtax['tag_plural']; | |
$labels = array( | |
'name' => _x( $tag_slug, 'taxonomy general name' ), | |
'singular_name' => _x( $tag_single, 'taxonomy singular name' ), | |
'search_items' => __( 'Search '.$tag_plural ), | |
'popular_items' => __( 'Popular '.$tag_plural ), | |
'all_items' => __( 'All '.$tag_plural ), | |
'parent_item' => null, | |
'parent_item_colon' => null, | |
'edit_item' => __( 'Edit '.$tag_single ), | |
'update_item' => __( 'Update '.$tag_single ), | |
'add_new_item' => __( 'Add New '.$tag_single ), | |
'new_item_name' => __( 'New '.$tag_single ), | |
'separate_items_with_commas' => __( 'Separate writers with commas' ), | |
'add_or_remove_items' => __( 'Add or remove '.$tag_plural ), | |
'choose_from_most_used' => __( 'Choose from the most used '.$tag_plural ), | |
'not_found' => __( 'None found.' ), | |
'menu_name' => __( $tag_plural), | |
); | |
$args = array( | |
'hierarchical' => true, | |
'labels' => $labels, | |
'show_ui' => true, | |
'show_admin_column' => false, | |
'update_count_callback' => '_update_post_term_count', | |
'query_var' => true, | |
'rewrite' => array( 'slug' => $tag_slug ), | |
); | |
register_taxonomy( $tag_slug, 'work', $args ); | |
} | |
} | |
// Register Custom Taxonomies | |
add_action( 'init', 'create_custom_taxonomies', 0 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment