Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Example: Biff’s LaserDisc Collection

This is an example used on jasoncharnes.com to show a LaserDisc collection as a Custom Post Type.

// Register Custom Post Type
function jc_laser_disc() {

	$labels = array(
		'name'                => _x( 'LaserDiscs', 'Post Type General Name', 'jc_laser_disc' ),
		'singular_name'       => _x( 'LaserDisc', 'Post Type Singular Name', 'jc_laser_disc' ),
		'menu_name'           => __( 'LaserDisc', 'jc_laser_disc' ),
		'parent_item_colon'   => __( 'Parent LaserDisc:', 'jc_laser_disc' ),
		'all_items'           => __( 'All LaserDiscs', 'jc_laser_disc' ),
		'view_item'           => __( 'View LaserDisc', 'jc_laser_disc' ),
		'add_new_item'        => __( 'Add New LaserDisc', 'jc_laser_disc' ),
		'add_new'             => __( 'Add New', 'jc_laser_disc' ),
		'edit_item'           => __( 'Edit LaserDisc', 'jc_laser_disc' ),
		'update_item'         => __( 'Update LaserDisc', 'jc_laser_disc' ),
		'search_items'        => __( 'Search LaserDisc', 'jc_laser_disc' ),
		'not_found'           => __( 'Not found', 'jc_laser_disc' ),
		'not_found_in_trash'  => __( 'Not found in Trash', 'jc_laser_disc' ),
	);
	$args = array(
		'label'               => __( 'jc_laser_disc', 'jc_laser_disc' ),
		'description'         => __( 'A collection of Biff's personal LaserDiscs.', 'jc_laser_disc' ),
		'labels'              => $labels,
		'supports'            => array( 'title', 'thumbnail', ),
		'hierarchical'        => false,
		'public'              => true,
		'show_ui'             => true,
		'show_in_menu'        => true,
		'show_in_nav_menus'   => true,
		'show_in_admin_bar'   => true,
		'menu_position'       => 5,
		'menu_icon'           => 'dashicons-video-alt3',
		'can_export'          => true,
		'has_archive'         => true,
		'exclude_from_search' => false,
		'publicly_queryable'  => true,
		'capability_type'     => 'page',
	);
	register_post_type( 'jc_laser_disc', $args );

}

// Hook into the 'init' action
add_action( 'init', 'jc_laser_disc', 0 );