Создал Custom Post Type с названием
projects,
создал файл
single-projects.php, он открывается при переходе по url site.com/projects/slug/
Как нужно назвать файл шаблона, чтобы он подгружался при заходе site.com/projects/ ?
Я назвал
projects.php — сайт при заходе на site.com/projects/ загружает index.php, как исправить?
Код Custom Post Type:
function register_projects_type(){
register_post_type('projects', [
'labels' => [
'name' => 'Проекты',
'singular_name' => 'Проект',
'add_new' => 'Добавить проект',
'add_new_item' => 'Добавление проекта',
'edit_item' => 'Редактирование проекта',
'new_item' => 'Новый проект',
'view_item' => 'Смотреть проект',
'search_items' => 'Искать проект',
'not_found' => 'Не найден',
'not_found_in_trash' => 'Не найден в корзине',
'parent_item_colon' => '',
'menu_name' => 'Проекты',
],
'description' => '',
'public' => true,
'show_in_menu' => true,
'show_in_rest' => true, // добавить в REST API. C WP 4.7
'rest_base' => 'projects', // $post_type. C WP 4.7
'menu_position' => 4,
'menu_icon' => 'dashicons-portfolio',
'hierarchical' => false,
'supports' => ['author', 'custom-fields', 'title', 'editor', 'thumbnail'],
'taxonomies' => [],
'has_archive' => true,
'rewrite' => true,
'rewrite' => ['slug' => 'projects'],
'query_var' => true,
]);
}
add_action('init', 'register_projects_type');