Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Courses post type

if ( ! function_exists('prakmed_course_post_type') ) {

// Register Custom Post Type
function prakmed_course_post_type() {

	$labels = array(
		'name'                  => _x( 'Courses', 'Post Type General Name', 'bam_courses_launcher' ),
		'singular_name'         => _x( 'Course', 'Post Type Singular Name', 'bam_courses_launcher' ),
		'menu_name'             => __( 'Courses', 'bam_courses_launcher' ),
		'name_admin_bar'        => __( 'Course', 'bam_courses_launcher' ),
		'archives'              => __( 'Course Archives', 'bam_courses_launcher' ),
		'attributes'            => __( 'Course Attributes', 'bam_courses_launcher' ),
		'parent_item_colon'     => __( 'Parent Course:', 'bam_courses_launcher' ),
		'all_items'             => __( 'All Courses', 'bam_courses_launcher' ),
		'add_new_item'          => __( 'Add New Course', 'bam_courses_launcher' ),
		'add_new'               => __( 'Add New', 'bam_courses_launcher' ),
		'new_item'              => __( 'New Course', 'bam_courses_launcher' ),
		'edit_item'             => __( 'Edit Course', 'bam_courses_launcher' ),
		'update_item'           => __( 'Update Course', 'bam_courses_launcher' ),
		'view_item'             => __( 'View Course', 'bam_courses_launcher' ),
		'view_items'            => __( 'View Courses', 'bam_courses_launcher' ),
		'search_items'          => __( 'Search Course', 'bam_courses_launcher' ),
		'not_found'             => __( 'Not found', 'bam_courses_launcher' ),
		'not_found_in_trash'    => __( 'Not found in Trash', 'bam_courses_launcher' ),
		'featured_image'        => __( 'Featured Image', 'bam_courses_launcher' ),
		'set_featured_image'    => __( 'Set featured image', 'bam_courses_launcher' ),
		'remove_featured_image' => __( 'Remove featured image', 'bam_courses_launcher' ),
		'use_featured_image'    => __( 'Use as featured image', 'bam_courses_launcher' ),
		'insert_into_item'      => __( 'Insert into course', 'bam_courses_launcher' ),
		'uploaded_to_this_item' => __( 'Uploaded to this course', 'bam_courses_launcher' ),
		'items_list'            => __( 'Courses list', 'bam_courses_launcher' ),
		'items_list_navigation' => __( 'Courses list navigation', 'bam_courses_launcher' ),
		'filter_items_list'     => __( 'Filter Courses list', 'bam_courses_launcher' ),
	);
	$rewrite = array(
		'slug'                  => 'course',
		'with_front'            => true,
		'pages'                 => true,
		'feeds'                 => true,
	);
	$args = array(
		'label'                 => __( 'Course', 'bam_courses_launcher' ),
		'description'           => __( 'A custom post type for courses', 'bam_courses_launcher' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor' ),
		'hierarchical'          => false,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 20,
		'menu_icon'             => 'dashicons-lightbulb',
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => true,
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'rewrite'               => $rewrite,
		'capability_type'       => 'post',
		'show_in_rest'          => true,
	);
	register_post_type( 'prakmed_course', $args );

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

}