Wordpress Custom Post Type Archive template doesn't load, instead of archive-event.php, it loads archive.php. here is my code:
function university_post_types() {
register_post_type('event', array(
'rewrite' => array('slug' => 'events'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Events',
'add_new_item' => 'Add New Event',
'edit_item' => 'Edit Event',
'all_items' => 'All Events',
'singular_name' => 'Event'
),
'menu_icon' => 'dashicons-calendar'
));
}
add_action('init', 'university_post_types');
Firstly, flush your permalinks by saving them in the settings page.
Then check your plugins. In my test site I had Beaver Builder and it was bypassing my archive-event.php
.
Edit: my original answer is not correct, the rewrite does not affect the template naming.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.