-
-
Save dexit/7f0e74f4503484c8624db3b8c54f5d98 to your computer and use it in GitHub Desktop.
CPT + Taxonomies Updated
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 | |
<?php | |
/* Register CPT */ | |
function cwptheme_post_type() { | |
$post_types_arr = array( 'Slider', 'Work', 'Staff', 'Map', 'Careers', 'Media', 'Events', 'Litigation', 'Advocacy', 'Guides' ); | |
foreach( $post_types_arr as $post_type_a){ | |
$labels = array( | |
'name' => __( $post_type_a ), | |
'singular_name' => __( $post_type_a), | |
'menu_name' => __( $post_type_a), | |
'parent_item_colon' => __( 'Parent '.$post_type_a), | |
'all_items' => __( 'All '.$post_type_a), | |
'view_item' => __( 'View '.$post_type_a), | |
'add_new_item' => __( 'Add New '.$post_type_a), | |
'add_new' => __( 'Add New'), | |
'edit_item' => __( 'Edit '.$post_type_a), | |
'update_item' => __( 'Update '.$post_type_a), | |
'search_items' => __( 'Search '.$post_type_a), | |
'not_found' => __( 'Not Found'), | |
'not_found_in_trash' => __( 'Not found in Trash') | |
); | |
$args = array( | |
'label' => __( $post_type_a), | |
'description' => __( 'Add '.$post_type_a), | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'custom-fields', 'page-attributes'), | |
'public' => true, | |
'hierarchical' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_nav_menus' => true, | |
'show_in_admin_bar' => true, | |
'has_archive' => true, | |
'can_export' => true, | |
'exclude_from_search' => false, | |
'yarpp_support' => true, | |
//'taxonomies' => array('category'), | |
'publicly_queryable' => true, | |
'capability_type' => 'page' | |
); | |
register_post_type( $post_type_a, $args ); | |
} | |
} | |
add_action( 'init', 'cwptheme_post_type', 0 ); | |
/**/ | |
/* Register Taxonomy */ | |
function taxoFunc($taxoName, $postType){ | |
$menuName = ucwords($taxoName); | |
$taxoName = strtolower(str_replace( ' ', '_', $taxoName)); | |
$labels = array( | |
'name' => _x( $menuName, 'taxonomy general name' ), | |
'singular_name' => _x( $menuName, 'taxonomy singular name' ), | |
'search_items' => __( 'Search' ), | |
'all_items' => __( 'All' ), | |
'parent_item' => __( 'Parent' ), | |
'parent_item_colon' => __( 'Parent:' ), | |
'edit_item' => __( 'Edit' ), | |
'update_item' => __( 'Update' ), | |
'add_new_item' => __( 'Add New' ), | |
'new_item_name' => __( 'New Name' ), | |
'menu_name' => __( $menuName ), | |
); | |
$args = array( | |
'hierarchical' => true, | |
'labels' => $labels, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => $taxoName, 'with_front' => false ), | |
); | |
register_taxonomy( $taxoName, $postType, $args ); | |
} | |
taxoFunc('Slider Categories', 'slider'); | |
taxoFunc('Work Categories', 'work'); | |
taxoFunc('Staff Categories', 'staff'); | |
taxoFunc('Map Categories', 'map'); | |
taxoFunc('Media Categories', 'media'); | |
taxoFunc('Careers Location', 'careers'); | |
taxoFunc('Careers Department', 'careers'); | |
taxoFunc('Careers Job Type', 'careers'); | |
taxoFunc('Events Categories', 'events'); | |
taxoFunc('Litigation Categories', 'litigation'); | |
taxoFunc('Litigation States', 'litigation'); | |
taxoFunc('Litigation Cases', 'litigation'); | |
taxoFunc('Advocacy Categories', 'advocacy'); | |
taxoFunc('Advocacy States', 'advocacy'); | |
taxoFunc('Guides Categories', 'guides'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment