Created
February 19, 2022 17:02
-
-
Save alexdeborba/4e1397faa3d1293747e5b8c37110aec9 to your computer and use it in GitHub Desktop.
CPT Docs
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
// Function to add Custom Post Type. | |
function olympus_custom_post_type() | |
{ | |
// Register the doc post type | |
register_post_type( 'docs', array( | |
'labels' => array( | |
'name' => esc_html__( 'Documentation', 'olympus' ), | |
'singular_name' => esc_html__( 'Document', 'olympus' ), | |
'add_new' => esc_html__( 'Add New', 'olympus' ), | |
'add_new_item' => esc_html__( 'Add New Document', 'olympus' ), | |
'edit_item' => esc_html__( 'Edit Document', 'olympus' ), | |
'new_item' => esc_html__( 'Add New Document', 'olympus' ), | |
'view_item' => esc_html__( 'View Document', 'olympus' ), | |
'search_items' => esc_html__( 'Search Document', 'olympus' ), | |
'not_found' => esc_html__( 'No Documents Found', 'olympus' ), | |
'not_found_in_trash' => esc_html__( 'No Documents Found In Trash', 'olympus' ), | |
'menu_name' => esc_html__( 'Documentation', 'olympus' ), | |
), | |
'public' => true, | |
'show_ui' => true, | |
'can_export' => true, | |
'show_in_rest' => true, | |
'capability_type' => 'page', | |
'rewrite' => array( 'slug' => 'documentation' ), | |
'supports' => array( 'title', 'editor' ), | |
) ); | |
// Register the doc taxonomy | |
register_taxonomy( 'doc_categories', array('docs'), array( | |
'hierarchical' => true, | |
'labels' => array( | |
'name' => _x( 'Categories', 'taxonomy general name', 'olympus' ), | |
'singular_name' => _x( 'Category', 'taxonomy singular name', 'olympus' ), | |
'search_items' => __( 'Search Categories', 'olympus' ), | |
'all_items' => __( 'All Categories', 'olympus' ), | |
'parent_item' => __( 'Parent Category', 'olympus' ), | |
'parent_item_colon' => __( 'Parent Category:', 'olympus' ), | |
'edit_item' => __( 'Edit Category', 'olympus' ), | |
'update_item' => __( 'Update Category', 'olympus' ), | |
'add_new_item' => __( 'Add New Category', 'olympus' ), | |
'new_item_name' => __( 'New Category Name', 'olympus' ), | |
'menu_name' => __( 'Categories', 'olympus' ), | |
), | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'doc-category' ), | |
) ); | |
} | |
add_action( 'init', 'olympus_custom_post_type' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment