Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

reference

if ( ! function_exists('fu_reference_custom_post_type') ) {

// Register Custom Post Type
function fu_reference_custom_post_type() {

	$labels = array(
		'name'                  => _x( 'References', 'Post Type General Name', 'fu' ),
		'singular_name'         => _x( 'Reference', 'Post Type Singular Name', 'fu' ),
		'menu_name'             => __( 'References', 'fu' ),
		'name_admin_bar'        => __( 'Reference', 'fu' ),
		'archives'              => __( 'Reference Archives', 'fu' ),
		'attributes'            => __( 'Reference Attributes', 'fu' ),
		'parent_item_colon'     => __( 'Parent Reference:', 'fu' ),
		'all_items'             => __( 'All References', 'fu' ),
		'add_new_item'          => __( 'Add New Reference', 'fu' ),
		'add_new'               => __( 'Add New', 'fu' ),
		'new_item'              => __( 'New Reference', 'fu' ),
		'edit_item'             => __( 'Edit Reference', 'fu' ),
		'update_item'           => __( 'Update Reference', 'fu' ),
		'view_item'             => __( 'View Reference', 'fu' ),
		'view_items'            => __( 'View References', 'fu' ),
		'search_items'          => __( 'Search Reference', 'fu' ),
		'not_found'             => __( 'Not found', 'fu' ),
		'not_found_in_trash'    => __( 'Not found in Trash', 'fu' ),
		'featured_image'        => __( 'Featured Image', 'fu' ),
		'set_featured_image'    => __( 'Set featured image', 'fu' ),
		'remove_featured_image' => __( 'Remove featured image', 'fu' ),
		'use_featured_image'    => __( 'Use as featured image', 'fu' ),
		'insert_into_item'      => __( 'Insert into reference', 'fu' ),
		'uploaded_to_this_item' => __( 'Uploaded to this reference', 'fu' ),
		'items_list'            => __( 'References list', 'fu' ),
		'items_list_navigation' => __( 'References list navigation', 'fu' ),
		'filter_items_list'     => __( 'Filter references list', 'fu' ),
	);
	$args = array(
		'label'                 => __( 'Reference', 'fu' ),
		'description'           => __( 'A documentation/knowledgebase article', 'fu' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail', 'revisions', 'custom-fields', 'page-attributes' ),
		'taxonomies'            => array( 'category', 'post_tag' ),
		'hierarchical'          => true,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 5,
		'menu_icon'             => 'dashicons-analytics',
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => true,
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'capability_type'       => 'page',
		'show_in_rest'          => true,
	);
	register_post_type( 'reference', $args );

}
add_action( 'init', 'fu_reference_custom_post_type', 0 );

}