最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - Custom post type template and custom post page not working

programmeradmin0浏览0评论

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.

  1. template-projects.php

  2. single-projects.php

Problem is, that when I go to: abc/projects - > I see index.php When I go to abc/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!

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.

  1. template-projects.php

  2. single-projects.php

Problem is, that when I go to: abc/projects - > I see index.php When I go to abc/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!

Share Improve this question asked Nov 6, 2019 at 20:46 xmigasxmigas 333 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

The correct template for abc/projects is archive-projects.php.

发布评论

评论列表(0)

  1. 暂无评论