JiveDig
5/9/2013 - 7:45 PM

Register custom post type, with Videos as the example

Register custom post type, with Videos as the example

<?php

// Register 'Videos' Post Type
if ( ! function_exists('jivedig_videos_post_type') ) {
function jivedig_videos_post_type() {
	$labels = array(
		'name'                => _x( 'Videos', 'executive' ),
		'singular_name'       => _x( 'Video', 'executive' ),
		'menu_name'           => __( 'Videos', 'executive' ),
		'parent_item_colon'   => __( 'Parent Video:', 'executive' ),
		'all_items'           => __( 'All Videos', 'executive' ),
		'view_item'           => __( 'View Video', 'executive' ),
		'add_new_item'        => __( 'Add New Video', 'executive' ),
		'add_new'             => __( 'New Video', 'executive' ),
		'edit_item'           => __( 'Edit Video', 'executive' ),
		'update_item'         => __( 'Update Video', 'executive' ),
		'search_items'        => __( 'Search Videos', 'executive' ),
		'not_found'           => __( 'No Videos found', 'executive' ),
		'not_found_in_trash'  => __( 'No Videos found in Trash', 'executive' ),
	);

	$rewrite = array(
		'slug'                => 'videos',
		'with_front'          => true,
		'pages'               => true,
		'feeds'               => true,
	);

	$args = array(
		'label'               => __( 'videos', 'executive' ),
		'description'         => __( 'Videos section of website', 'executive' ),
		'labels'              => $labels,
		'supports'            => array( 'title', 'editor', 'author', 'thumbnail', 'comments' ),
/* 		'taxonomies'          => array( 'category', 'post_tag' ), */
		'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'           => '', */
		'can_export'          => true,
		'has_archive'         => true,
		'exclude_from_search' => false,
		'publicly_queryable'  => true,
		'query_var'           => 'videos',
		'rewrite'             => $rewrite,
		'capability_type'     => 'page',
	);
	
	register_post_type( 'videos', $args );
}
// Hook into the 'init' action
add_action( 'init', 'jivedig_videos_post_type', 0 );
}