Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

PGAM Gallery

// Register Custom Post Type
function custom_post_type() {

	$labels = array(
		'name'                => 'Gallery',
		'singular_name'       => 'Image',
		'menu_name'           => 'Gallery',
		'name_admin_bar'      => 'Gallery',
		'parent_item_colon'   => 'Parent Gallery:',
		'all_items'           => 'All Images',
		'add_new_item'        => 'Add New Image',
		'add_new'             => 'Add New',
		'new_item'            => 'New Image',
		'edit_item'           => 'Edit Image',
		'update_item'         => 'Update Image',
		'view_item'           => 'View Image',
		'search_items'        => 'Search for Image',
		'not_found'           => 'Not found',
		'not_found_in_trash'  => 'Not found in Trash',
	);
	$rewrite = array(
		'slug'                => 'gallery',
		'with_front'          => true,
		'pages'               => true,
		'feeds'               => false,
	);
	$args = array(
		'label'               => 'Image',
		'labels'              => $labels,
		'supports'            => array( 'title', ),
		'taxonomies'          => array( 'gcategory' ),
		'hierarchical'        => true,
		'public'              => true,
		'show_ui'             => true,
		'show_in_menu'        => true,
		'menu_position'       => 25,
		'menu_icon'           => 'dashicons-grid-view',
		'show_in_admin_bar'   => false,
		'show_in_nav_menus'   => false,
		'can_export'          => true,
		'has_archive'         => true,		
		'exclude_from_search' => true,
		'publicly_queryable'  => true,
		'rewrite'             => $rewrite,
		'capability_type'     => 'page',
	);
	register_post_type( 'gallery_cpt', $args );

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