-
-
Save gbissland/53a2f2fc49ea5d819318aa172e0ee33f to your computer and use it in GitHub Desktop.
Register the ht_kb custom post type
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
/** | |
* Register the ht_kb custom post type | |
*/ | |
function register_ht_knowledge_base_cpt(){ | |
if(apply_filters('ht_kb_disable_ht_kb_cpt', false)){ | |
return; | |
} | |
$singular_item = _x('Article', 'Post Type Singular Name', 'ht-knowledge-base'); | |
$plural_item = _x('Articles', 'Post Type Plural Name', 'ht-knowledge-base'); | |
$kb_item = __('Knowledge Base', 'ht-knowledge-base'); | |
$rewrite = $this->get_cpt_slug(); | |
$show_in_rest = apply_filters('ht_kb_show_in_rest', true); | |
$rest_base = apply_filters('ht_kb_rest_base', 'ht-kb'); | |
$has_archive = apply_filters('ht_kb_cpt_has_archive', true); | |
$labels = array( | |
'name' => $plural_item, | |
'singular_name' => $singular_item, | |
'add_new' => __('Add New', 'ht-knowledge-base') . ' ' . $singular_item, | |
'add_new_item' => __('Add New', 'ht-knowledge-base') . ' ' . $singular_item, | |
'edit_item' => __('Edit', 'ht-knowledge-base') . ' ' . $singular_item, | |
'new_item' => __('New', 'ht-knowledge-base') . ' ' . $singular_item, | |
'all_items' => __('All', 'ht-knowledge-base') . ' ' . $plural_item, | |
'view_item' => __('View', 'ht-knowledge-base') . ' ' . $singular_item, | |
'search_items' => __('Search', 'ht-knowledge-base') . ' ' . $plural_item, | |
'not_found' => sprintf( __( 'No %s found', 'ht-knowledge-base' ), $plural_item ), | |
'not_found_in_trash' => sprintf( __( 'No %s found in trash', 'ht-knowledge-base' ), $plural_item ), | |
'parent_item_colon' => '', | |
'menu_name' => $kb_item, | |
); | |
$args = array( | |
'labels' => $labels, | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_nav_menus' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => $rewrite, 'with_front' => false ), | |
'capability_type' => 'post', | |
'has_archive' => $has_archive, | |
'hierarchical' => false, | |
'show_in_rest' => $show_in_rest, | |
'rest_base' => $rest_base, | |
'menu_icon' => 'dashicons-lightbulb', | |
'menu_position' => null, | |
'supports' => apply_filters( 'ht_kb_cpt_supports', array( 'title', 'editor', 'author', 'comments', 'post-formats', 'custom-fields', 'revisions', 'publicize', 'wpcom-markdown', 'excerpt' ) ) | |
); | |
register_post_type( 'ht_kb', $args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment