I've declared a custom post type as below, I can create posts in admin but when I try to view I'm getting 404 error. I've declared a previous custom post type using similar code and it worked fine. I don't want an archive page, but do want single post pages.
I've tried flushing the rewrite rules, and deactivating plugins but neither has worked. Any help would be greatly appreciated!!
//create courses post type
add_action( 'init', 'create_courses_post_type' );
function create_courses_post_type() {
$labels = array(
'name' => __( 'Courses' ),
'singular_name' => __( 'Course' ),
'all_items' => __( 'All Courses' ),
'add_new' => _x( 'Add New Course', 'Courses' ),
'add_new_item' => __( 'Add New Course' ),
'edit_item' => __( 'Edit Course' ),
'new_item' => __( 'New Course' ),
'view_item' => __( 'View Course' ),
'search_items' => __( 'Search in Courses' ),
'not_found' => __( 'No Courses found' ),
'not_found_in_trash' => __( 'No Courses found in trash' ),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => false, // Set to false hides Archive Pages
'menu_icon' => 'dashicons-welcome-learn-more', //pick one here ~> https://developer.wordpress.org/resource/dashicons/
'rewrite' => array( 'slug' => 'courses' ),
'taxonomies' => array( 'category', 'post_tag' ),
'query_var' => true,
'menu_position' => 9,
'publicly_queryable' => true
);
register_post_type( 'course', $args );
}