Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Content Block Post Type

if ( ! function_exists('block') ) {

// Register Custom Post Type
function block() {

	$labels = array(
		'name'                  => _x( 'Content Blocks', 'Post Type General Name', 'mpress' ),
		'singular_name'         => _x( 'Content Block', 'Post Type Singular Name', 'mpress' ),
		'menu_name'             => __( 'Content Blocks', 'mpress' ),
		'name_admin_bar'        => __( 'Content Blocks', 'mpress' ),
		'archives'              => __( 'Item Archives', 'mpress' ),
		'attributes'            => __( 'Item Attributes', 'mpress' ),
		'parent_item_colon'     => __( 'Parent Block:', 'mpress' ),
		'all_items'             => __( 'All Blocks', 'mpress' ),
		'add_new_item'          => __( 'Add New Block', 'mpress' ),
		'add_new'               => __( 'Add New', 'mpress' ),
		'new_item'              => __( 'New Block', 'mpress' ),
		'edit_item'             => __( 'Edit Block', 'mpress' ),
		'update_item'           => __( 'Update Block', 'mpress' ),
		'view_item'             => __( 'View Block', 'mpress' ),
		'view_items'            => __( 'View Items', 'mpress' ),
		'search_items'          => __( 'Search Blocks', 'mpress' ),
		'not_found'             => __( 'Not found', 'mpress' ),
		'not_found_in_trash'    => __( 'Not found in Trash', 'mpress' ),
		'featured_image'        => __( 'Background Image', 'mpress' ),
		'set_featured_image'    => __( 'Set background image', 'mpress' ),
		'remove_featured_image' => __( 'Remove background image', 'mpress' ),
		'use_featured_image'    => __( 'Use as background image', 'mpress' ),
		'insert_into_item'      => __( 'Insert into item', 'mpress' ),
		'uploaded_to_this_item' => __( 'Uploaded to this item', 'mpress' ),
		'items_list'            => __( 'Block list', 'mpress' ),
		'items_list_navigation' => __( 'Block list navigation', 'mpress' ),
		'filter_items_list'     => __( 'Filter block list', 'mpress' ),
	);
	$args = array(
		'label'                 => __( 'Content Block', 'mpress' ),
		'description'           => __( 'Content Blocks', 'mpress' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
		'hierarchical'          => true,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 20,
		'menu_icon'             => 'dashicons-text',
		'show_in_admin_bar'     => false,
		'show_in_nav_menus'     => false,
		'can_export'            => true,
		'has_archive'           => false,		
		'exclude_from_search'   => true,
		'publicly_queryable'    => true,
		'capability_type'       => 'page',
	);
	register_post_type( 'block', $args );

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

}