I am creating custom post types using this code
function create_custom_post_type() {
register_post_type('courses',
array(
'labels' => array(
'name' => __('Courses'),
'singular_name' => __('Course')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'courses'),
'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
'taxonomies' => array('category')
)
);
}
add_action('init', 'create_custom_post_type');
This code successfully works and shows and the archive pages shows as well but the posts give a 404 error, If i name the custom post types anything else like Lessons then it works I have done everything like cleared the rewrite rules, saved the permalink settings again after creating a post but it does not work Can anyone help Thanks,
courses
is quite generic are you sure there isn't already a CPT with the same slug? I also saw you put'rewrite' => array('slug' => 'courses'),
in the code but this seems unnecessary given the CPT already has the namecourses
and is probably causing problems. Have you used a rewrite rules tester plugin to confirm it matches the rules from the CPT and not something 3rd party/something else it shouldn't?