In my plugin, I'm creating a custom post type that has an archive and uses the rewrite parameter to choose a slug:
$args = array (
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'lessons', 'with_front' => false)
);
register_post_type ('my_plugin_lesson', $args);
With this code, I get an archive of the 'my_plugin_lesson' posts at example.com/lessons/
.
However, I can also create a Page with the title "Lessons", and WordPress will assign it the slug 'lessons'. The View Page link on the admin panel for this page will be example.com/lessons/
, but the page is inaccessible because WordPress shows the archive for my custom post type.
Is there a way to prevent WordPress from choosing a slug for pages or posts that interfere with the slug of my custom post types?