Created
February 3, 2022 18:35
-
-
Save gravnetic/b3ef2225fc4c6cd33191dc681dcaeff2 to your computer and use it in GitHub Desktop.
Register CPTs and Taxonomy
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 | |
| //Posts priority area category | |
| add_action( 'init', 'create_prioritycat' ); | |
| function create_prioritycat(){ | |
| register_taxonomy( 'priority-cat', [ 'post' ], [ | |
| 'label' => '', | |
| 'labels' => [ | |
| 'name' => 'Priority areas', | |
| 'singular_name' => 'Priority area', | |
| 'search_items' => 'Search Priority areas', | |
| 'all_items' => 'All Priority areas', | |
| 'view_item ' => 'View Priority area', | |
| 'parent_item' => 'Parent Priority area', | |
| 'parent_item_colon' => 'Parent Priority area:', | |
| 'edit_item' => 'Edit Priority area', | |
| 'update_item' => 'Update Priority area', | |
| 'add_new_item' => 'Add New Priority area', | |
| 'new_item_name' => 'New Priority area', | |
| 'menu_name' => 'Priority area', | |
| ], | |
| 'description' => '', | |
| 'public' => true, | |
| 'hierarchical' => true, | |
| 'rewrite' => true, | |
| 'capabilities' => array(), | |
| 'meta_box_cb' => null, | |
| 'show_admin_column' => true, | |
| 'show_in_rest' => null, | |
| 'rest_base' => null, // $taxonomy | |
| ] ); | |
| } | |
| //staff | |
| add_action( 'init', 'create_staff' ); | |
| if (!function_exists('create_staff')) { | |
| function create_staff() { | |
| register_post_type('staff', | |
| [ | |
| 'labels' => [ | |
| 'name' => __('Staff','mmhpi'), | |
| 'singular_name' => __('Staff Page','mmhpi'), | |
| 'add_new' => __('Add New', 'mmhpi'), | |
| 'add_new_item' => __('Add Staff Page','mmhpi'), | |
| 'edit_item' => __('Edit Staff Page','mmhpi'), | |
| 'new_item' => __('New Staff Page','mmhpi'), | |
| 'all_items' => __('Staff Pages','mmhpi'), | |
| ], | |
| 'menu_position' => 10, | |
| 'menu_icon' => 'dashicons-admin-page', | |
| 'supports' => array('title', 'page-attributes', 'thumbnail'), | |
| 'rewrite' => array('slug' => 'staff','hierarchical'=>false, 'with_front'=>false, 'feed'=>false ), | |
| 'hierarchical' => true, | |
| 'show_ui' => true, | |
| 'show_in_nav_menus' => true, | |
| 'query_var' => true, | |
| 'public' => true, | |
| 'exclude_from_search' => false, | |
| 'publicly_queryable' => true, | |
| 'capability_type' => 'page', | |
| 'has_archive' => true, | |
| 'supports' => array('title', 'excerpt', 'editor', 'thumbnail','custom-fields') | |
| ] | |
| ); | |
| } | |
| } | |
| //staff category | |
| add_action( 'init', 'create_staff_type' ); | |
| function create_staff_type(){ | |
| register_taxonomy( 'staff-types', [ 'staff' ], [ | |
| 'label' => '', | |
| 'labels' => [ | |
| 'name' => 'Departments', | |
| 'singular_name' => 'Department', | |
| 'search_items' => 'Search Department', | |
| 'all_items' => 'All Departments', | |
| 'view_item ' => 'View Department', | |
| 'parent_item' => 'Parent Department', | |
| 'parent_item_colon' => 'Parent Department:', | |
| 'edit_item' => 'Edit Department', | |
| 'update_item' => 'Update Department', | |
| 'add_new_item' => 'Add New Department', | |
| 'new_item_name' => 'New Department Name', | |
| 'menu_name' => 'Departments', | |
| ], | |
| 'description' => '', | |
| 'public' => true, | |
| 'hierarchical' => true, | |
| 'rewrite' => true, | |
| 'capabilities' => array(), | |
| 'meta_box_cb' => null, | |
| 'show_admin_column' => true, | |
| 'show_in_rest' => null, | |
| 'rest_base' => null, // $taxonomy | |
| ] ); | |
| } | |
| //event | |
| add_action( 'init', 'create_event_type' ); | |
| if (!function_exists('create_event_type')) { | |
| function create_event_type() { | |
| register_post_type('event', | |
| [ | |
| 'labels' => [ | |
| 'name' => __('Events','mmhpi'), | |
| 'singular_name' => __('Event Page','mmhpi'), | |
| 'add_new_item' => __('Add Event Page','mmhpi'), | |
| 'edit_item' => __('Edit Event Page','mmhpi'), | |
| 'new_item' => __('New Event Page','mmhpi'), | |
| 'all_items' => __('All Events Pages','mmhpi'), | |
| ], | |
| 'menu_position' => 10, | |
| 'menu_icon' => 'dashicons-calendar-alt', | |
| 'supports' => array('title', 'page-attributes', 'thumbnail'), | |
| 'rewrite' => array('slug' => 'event','hierarchical'=>false, 'with_front'=>false, 'feed'=>false ), | |
| 'hierarchical' => true, | |
| 'show_ui' => true, | |
| 'show_in_nav_menus' => true, | |
| 'query_var' => true, | |
| 'public' => true, | |
| 'has_archive' => true, | |
| 'supports' => array('title', 'excerpt', 'editor', 'thumbnail') | |
| ] | |
| ); | |
| } | |
| } | |
| //policy | |
| add_action( 'init', 'create_policy_type' ); | |
| if (!function_exists('create_policy_type')) { | |
| function create_policy_type() { | |
| register_post_type('policy', | |
| [ | |
| 'labels' => [ | |
| 'name' => __('Policies','mmhpi'), | |
| 'singular_name' => __('Policy Page','mmhpi'), | |
| 'add_new_item' => __('Add Policy Page','mmhpi'), | |
| 'edit_item' => __('Edit Policy Page','mmhpi'), | |
| 'new_item' => __('New Policy Page','mmhpi'), | |
| 'all_items' => __('All Policy Pages','mmhpi'), | |
| ], | |
| 'menu_position' => 10, | |
| 'menu_icon' => 'dashicons-media-document', | |
| 'supports' => array('title', 'page-attributes', 'thumbnail'), | |
| 'rewrite' => array('slug' => 'policy','hierarchical'=>false, 'with_front'=>false, 'feed'=>false ), | |
| 'hierarchical' => false, | |
| 'show_ui' => true, | |
| 'show_in_nav_menus' => true, | |
| 'query_var' => true, | |
| 'public' => true, | |
| 'has_archive' => true, | |
| 'taxonomies' => array('post_tag'), | |
| 'supports' => array('title', 'excerpt', 'editor', 'thumbnail') | |
| ] | |
| ); | |
| } | |
| } | |
| //policy tag | |
| add_action( 'init', 'create_policytag' ); | |
| function create_policytag(){ | |
| register_taxonomy( 'policytype', [ 'policy' ], [ | |
| 'label' => '', | |
| 'labels' => [ | |
| 'name' => 'Legislative Session', | |
| 'singular_name' => 'Legislative Session', | |
| 'search_items' => 'Search Legislative Sessions', | |
| 'all_items' => 'All Legislative Sessions', | |
| 'view_item ' => 'View Legislative Sessions', | |
| 'parent_item' => 'Parent Legislative Session', | |
| 'parent_item_colon' => 'Parent Legislative Session:', | |
| 'edit_item' => 'Edit Legislative Session', | |
| 'update_item' => 'Update Legislative Session', | |
| 'add_new_item' => 'Add New Legislative Session', | |
| 'new_item_name' => 'New Legislative Session', | |
| 'menu_name' => 'Legislative Session', | |
| ], | |
| 'description' => '', | |
| 'public' => true, | |
| 'hierarchical' => true, | |
| 'rewrite' => true, | |
| 'capabilities' => array(), | |
| 'meta_box_cb' => null, | |
| 'show_admin_column' => true, | |
| 'show_in_rest' => null, | |
| 'rest_base' => null, // $taxonomy | |
| ] ); | |
| } | |
| //case study | |
| add_action( 'init', 'create_casestudy_type' ); | |
| if (!function_exists('create_casestudy_type')) { | |
| function create_casestudy_type() { | |
| register_post_type('casestudy', | |
| [ | |
| 'labels' => [ | |
| 'name' => __('Case study','mmhpi'), | |
| 'singular_name' => __('Case study ','mmhpi'), | |
| 'add_new_item' => __('Add Case study ','mmhpi'), | |
| 'edit_item' => __('Edit Case study ','mmhpi'), | |
| 'new_item' => __('New Case study ','mmhpi'), | |
| 'all_items' => __('All Case studies','mmhpi'), | |
| ], | |
| 'menu_position' => 10, | |
| //'menu_icon' => 'dashicons-calendar-alt', | |
| 'supports' => array('title', 'page-attributes', 'thumbnail'), | |
| 'rewrite' => array('slug' => 'casestudy','hierarchical'=>false, 'with_front'=>false, 'feed'=>false ), | |
| 'hierarchical' => true, | |
| 'show_ui' => true, | |
| 'show_in_nav_menus' => true, | |
| 'query_var' => true, | |
| 'public' => true, | |
| 'has_archive' => true, | |
| 'supports' => array('title', 'excerpt', 'editor', 'thumbnail') | |
| ] | |
| ); | |
| } | |
| } | |
| //project | |
| add_action( 'init', 'create_project_type' ); | |
| if (!function_exists('create_project_type')) { | |
| function create_project_type() { | |
| register_post_type('project', | |
| [ | |
| 'labels' => [ | |
| 'name' => __('Projects','mmhpi'), | |
| 'singular_name' => __('Project Page','mmhpi'), | |
| 'add_new_item' => __('Add Project Page','mmhpi'), | |
| 'edit_item' => __('Edit Project Page','mmhpi'), | |
| 'new_item' => __('New Project Page','mmhpi'), | |
| 'all_items' => __('All Projects Pages','mmhpi'), | |
| ], | |
| 'menu_position' => 10, | |
| 'menu_icon' => 'dashicons-text-page', | |
| 'supports' => array('title', 'page-attributes', 'thumbnail'), | |
| 'rewrite' => array('slug' => 'project','hierarchical'=>false, 'with_front'=>false, 'feed'=>false ), | |
| 'hierarchical' => false, | |
| 'show_ui' => true, | |
| 'show_in_nav_menus' => true, | |
| 'query_var' => true, | |
| 'public' => true, | |
| 'has_archive' => true, | |
| 'taxonomies' => array('post_tag'), | |
| 'supports' => array('title', 'excerpt', 'editor', 'thumbnail') | |
| ] | |
| ); | |
| } | |
| } | |
| //project category | |
| add_action( 'init', 'create_projecttype' ); | |
| function create_projecttype(){ | |
| register_taxonomy( 'projecttype', [ 'project' ], [ | |
| 'label' => '', | |
| 'labels' => [ | |
| 'name' => 'Types', | |
| 'singular_name' => 'Type', | |
| 'search_items' => 'Search Types', | |
| 'all_items' => 'All Types', | |
| 'view_item ' => 'View Type', | |
| 'parent_item' => 'Parent Tag', | |
| 'parent_item_colon' => 'Parent Type:', | |
| 'edit_item' => 'Edit Type', | |
| 'update_item' => 'Update Type', | |
| 'add_new_item' => 'Add New Type', | |
| 'new_item_name' => 'New Type Name', | |
| 'menu_name' => 'Type', | |
| ], | |
| 'description' => '', | |
| 'public' => true, | |
| 'hierarchical' => true, | |
| 'rewrite' => true, | |
| 'capabilities' => array(), | |
| 'meta_box_cb' => null, | |
| 'show_admin_column' => true, | |
| 'show_in_rest' => null, | |
| 'rest_base' => null, // $taxonomy | |
| ] ); | |
| } | |
| //learning library | |
| add_action( 'init', 'create_library_type' ); | |
| if (!function_exists('create_library_type')) { | |
| function create_library_type() { | |
| register_post_type('library', | |
| [ | |
| 'labels' => [ | |
| 'name' => __('TAG Library','mmhpi'), | |
| 'singular_name' => __('Library Post','mmhpi'), | |
| 'add_new_item' => __('Add Library Post','mmhpi'), | |
| 'edit_item' => __('Edit Library Post','mmhpi'), | |
| 'new_item' => __('New Library Post','mmhpi'), | |
| 'all_items' => __('All Library Posts','mmhpi'), | |
| ], | |
| 'menu_position' => 10, | |
| 'menu_icon' => 'dashicons-admin-page', | |
| 'supports' => array('title', 'page-attributes', 'thumbnail'), | |
| 'rewrite' => array('slug' => 'learning-library','hierarchical'=>false, 'with_front'=>false, 'feed'=>false ), | |
| 'hierarchical' => false, | |
| 'show_ui' => true, | |
| 'show_in_nav_menus' => true, | |
| 'query_var' => true, | |
| 'public' => true, | |
| 'has_archive' => true, | |
| 'taxonomies' => array('post_tag'), | |
| 'supports' => array('title', 'excerpt', 'editor', 'thumbnail') | |
| ] | |
| ); | |
| } | |
| } | |
| //statistics | |
| add_action( 'init', 'create_statistic_type' ); | |
| if (!function_exists('create_statistic_type')) { | |
| function create_statistic_type() { | |
| register_post_type('statistic', | |
| [ | |
| 'labels' => [ | |
| 'name' => __('Statistic','mmhpi'), | |
| 'singular_name' => __('Statistic','mmhpi'), | |
| 'add_new_item' => __('Add Statistic','mmhpi'), | |
| 'edit_item' => __('Edit Statistic','mmhpi'), | |
| 'new_item' => __('New Statistic','mmhpi'), | |
| 'all_items' => __('All Statistics','mmhpi'), | |
| ], | |
| 'menu_position' => 10, | |
| 'menu_icon' => 'dashicons-chart-pie', | |
| 'supports' => array('title', 'page-attributes', 'thumbnail'), | |
| 'rewrite' => array('slug' => 'statistic','hierarchical'=>false, 'with_front'=>false, 'feed'=>false ), | |
| 'hierarchical' => true, | |
| 'show_ui' => true, | |
| 'show_in_nav_menus' => true, | |
| 'query_var' => true, | |
| 'public' => true, | |
| 'has_archive' => true, | |
| 'supports' => array('title', 'excerpt', 'editor', 'thumbnail') | |
| ] | |
| ); | |
| } | |
| } | |
| //statistics group | |
| add_action( 'init', 'create_group' ); | |
| function create_group(){ | |
| register_taxonomy( 'group', [ 'statistic' ], [ | |
| 'label' => '', | |
| 'labels' => [ | |
| 'name' => 'Groups', | |
| 'singular_name' => 'Group', | |
| 'search_items' => 'Search Groups', | |
| 'all_items' => 'All Groups', | |
| 'view_item ' => 'View Group', | |
| 'parent_item' => 'Parent Group', | |
| 'parent_item_colon' => 'Parent Group:', | |
| 'edit_item' => 'Edit Group', | |
| 'update_item' => 'Update Group', | |
| 'add_new_item' => 'Add New Group', | |
| 'new_item_name' => 'New Group Name', | |
| 'menu_name' => 'Group', | |
| ], | |
| 'description' => '', | |
| 'public' => true, | |
| 'hierarchical' => true, | |
| 'rewrite' => true, | |
| 'capabilities' => array(), | |
| 'meta_box_cb' => null, | |
| 'show_admin_column' => false, | |
| 'show_in_rest' => null, | |
| 'rest_base' => null, // $taxonomy | |
| ] ); | |
| } | |
| //statistics region | |
| add_action( 'init', 'create_region' ); | |
| function create_region(){ | |
| register_taxonomy( 'region', [ 'statistic' ], [ | |
| 'label' => '', | |
| 'labels' => [ | |
| 'name' => 'Regions', | |
| 'singular_name' => 'Region', | |
| 'search_items' => 'Search Regions', | |
| 'all_items' => 'All Regions', | |
| 'view_item ' => 'View Region', | |
| 'parent_item' => 'Parent Region', | |
| 'parent_item_colon' => 'Parent Region:', | |
| 'edit_item' => 'Edit Region', | |
| 'update_item' => 'Update Region', | |
| 'add_new_item' => 'Add New Region', | |
| 'new_item_name' => 'New Region Name', | |
| 'menu_name' => 'Region', | |
| ], | |
| 'description' => '', | |
| 'public' => true, | |
| 'hierarchical' => true, | |
| 'rewrite' => true, | |
| 'capabilities' => array(), | |
| 'meta_box_cb' => null, | |
| 'show_admin_column' => false, | |
| 'show_in_rest' => null, | |
| 'rest_base' => null, // $taxonomy | |
| ] ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment