Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
function hck_questions_cpt() {
$labels = array(
'name' => _x( 'Topics', 'healthcarekit' ),
'singular_name' => _x( 'Topic', 'healthcarekit' ),
'search_items' => __( 'Search Topics', 'healthcarekit' ),
'all_items' => __( 'All Topics', 'healthcarekit' ),
'parent_item' => __( 'Parent Topic', 'healthcarekit' ),
'parent_item_colon' => __( 'Parent Topic:', 'healthcarekit' ),
'edit_item' => __( 'Edit Topic', 'healthcarekit' ),
'update_item' => __( 'Update Topic', 'healthcarekit' ),
'add_new_item' => __( 'Add New Topic', 'healthcarekit' ),
'new_item_name' => __( 'New Topic', 'healthcarekit' ),
'menu_name' => __( 'Topics', 'healthcarekit' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'topics' ),
//'rewrite' => false
);
//shared taxonomy - each CPT here also sets 'taxonomies' => array( 'topics' )
register_taxonomy( 'topics', array( 'articles', 'questions', 'amas' ), $args );
$labels = array(
'name' => _x( 'Questions', 'healthcarekit' ),
'singular_name' => _x( 'Question', 'healthcarekit' ),
'menu_name' => __( 'Questions', 'healthcarekit' ),
'name_admin_bar' => __( 'Questions', 'healthcarekit' ),
'archives' => __( 'Questions', 'healthcarekit' ),
'parent_item_colon' => __( 'Parent Question:', 'healthcarekit' ),
'all_items' => __( 'All Questions', 'healthcarekit' ),
'add_new_item' => __( 'Add New Question', 'healthcarekit' ),
'add_new' => __( 'Add New', 'healthcarekit' ),
'new_item' => __( 'New Question', 'healthcarekit' ),
'edit_item' => __( 'Edit Question', 'healthcarekit' ),
'update_item' => __( 'Update Question', 'healthcarekit' ),
'view_item' => __( 'View Question', 'healthcarekit' ),
'search_items' => __( 'Search Questions', 'healthcarekit' ),
'not_found' => __( 'Not found', 'healthcarekit' ),
'not_found_in_trash' => __( 'Not found in Trash', 'healthcarekit' ),
'featured_image' => __( 'Featured Image', 'healthcarekit' ),
'set_featured_image' => __( 'Set Question image', 'healthcarekit' ),
'remove_featured_image' => __( 'Remove Question image', 'healthcarekit' ),
'use_featured_image' => __( 'Use as Question image', 'healthcarekit' ),
'insert_into_item' => __( 'Insert into item', 'healthcarekit' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'healthcarekit' ),
'items_list' => __( 'Items list', 'healthcarekit' ),
'items_list_navigation' => __( 'Items list navigation', 'healthcarekit' ),
'filter_items_list' => __( 'Filter items list', 'healthcarekit' ),
);
$args = array(
'label' => __( 'Question', 'healthcarekit' ),
'description' => __( 'Questions', 'healthcarekit' ),
'labels' => $labels,
'supports' => array( 'title','editor', 'author', 'comments' ),
'taxonomies' => array( 'topics' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'show_in_rest' => true,
'has_archive' => 'questions',
'exclude_from_search' => false,
'publicly_queryable' => true,
'query_var' => true,
'capability_type' => 'post',
'rewrite' => array( 'slug' => 'question' ),
);
register_post_type( 'questions', $args );
}
add_action( 'init', 'hck_questions_cpt', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.