Custom post type template and custom post page not working

I have created custom post type “projects” in functions.php like this:

register_post_type(‘projects’,
array(
‘rewrite’ => array(‘slug’ => ‘projects’),
‘labels’ => array(
‘name’ => ‘projects’,
‘singular_name’ => ‘project’,
‘add_new_item’ => ‘Add new project’,
‘edit_item’ => ‘Edit project’
),
‘menu-icon’ => ‘dashicons-clipboard’,
‘public’ => true,
‘has_archive’ => true,
‘supports’ => array(
‘title’, ‘thumbnail’, ‘editor’, ‘excerpt’, ‘comments’
)
));

I’ve used add_action of course.
Then I’ve created two files.

template-projects.php

single-projects.php

Problem is, that when I go to: abc.com/projects – > I see index.php
When I go to abc.com/projects/project-1 – > I see detail of the project (this is somehow working). I tried to update permalinks via Settings, but it’s not working. Before this update /projects was working, but /projects/project-1 wasn’t.

Do you guys now how to fix this? Thanks!

Read more here:: Custom post type template and custom post page not working

Leave a Reply

Your email address will not be published. Required fields are marked *