Add Snippet To Project
<?php
// Register custom post type for courses
function wpturbo_register_course_post_type() {
$labels = array(
'name' => __( 'Courses', 'wpturbo' ),
'singular_name' => __( 'Course', 'wpturbo' ),
'menu_name' => __( 'Courses', 'wpturbo' ),
'add_new' => __( 'Add New', 'wpturbo' ),
'add_new_item' => __( 'Add New Course', 'wpturbo' ),
'edit' => __( 'Edit', 'wpturbo' ),
'edit_item' => __( 'Edit Course', 'wpturbo' ),
'new_item' => __( 'New Course', 'wpturbo' ),
'view' => __( 'View', 'wpturbo' ),
'view_item' => __( 'View Course', 'wpturbo' ),
'search_items' => __( 'Search Courses', 'wpturbo' ),
'not_found' => __( 'No courses found', 'wpturbo' ),
'not_found_in_trash' => __( 'No courses found in Trash', 'wpturbo' ),
'parent' => __( 'Parent Course', 'wpturbo' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'has_archive' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-calendar-alt',
'supports' => array( 'title', 'editor', 'thumbnail' ),
);
register_post_type( 'course', $args );
}
add_action( 'init', 'wpturbo_register_course_post_type' );
This code registers a new custom post type called "Courses" with the necessary labels and settings. It also adds support for a title, editor, and thumbnail for each course.
Next, you can create a custom meta box to add additional information to each course, such as the duration and target audience. Here's an example code snippet to add a custom meta box:
This code adds a meta box to the course editing screen where you can enter the duration and target audience. The values are saved as custom meta data for each course.
With these code snippets, you can now create and manage courses on your website. You can further enhance the plugin by adding features such as course filtering, registration forms, and payment integration.
Remember to replace the <div class="had-elegant-themes-content"></div> with the code snippets provided above.