简体   繁体   English

WordPress自定义帖子永久链接模板

[英]Wordpress custom post permalink template

I got a new posttype called "butik". 我得到了一个称为“ butik”的新帖子。 But I want to be able to edit the template for that post, right now it uses index.php, and I have tried creating single-butik.php but it still wont use that. 但是我希望能够编辑该帖子的模板,现在它使用index.php,并且我尝试创建single-butik.php,但它仍然不会使用它。

Can anyone help me? 谁能帮我?

Edit 1: 编辑1:

This is my function to register the post type: 这是我注册帖子类型的功能:

register_post_type("butik", [
    "labels" => [
        "name" => "Butik",
        "singular_name" => "Butik"
    ],
    "show_ui" => true,
    "supports" => [
        "title",
        "editor",
        "thumbnail"
    ]
]);

First, make sure that your post type is called butik exactly in your register_post_type function. 首先,请确保在register_post_type函数中准确地将您的帖子类型称为butik。

Secondly, if you're seeing index.php it indicates that wordpress is expecting to serve up the template that lists all posts within that post-type, otherwise it would be serving up single.php - which is used when wordpress expects to serve up an individual post. 其次,如果您看到index.php,则表明wordpress期望提供列出该帖子类型内所有帖子的模板,否则它将提供single.php-当wordpress期望提供服务时使用个人帖子。

These types of pages that list all posts are referred to as 'archive' pages, so instead try editing archive-butik.php 列出所有帖子的这些页面类型称为“存档”页面,因此,请尝试编辑archive-butik.php

single.php displays one single post. single.php显示一个帖子。 Chances are the url doesn't specify an individual post. 网址可能未指定单个帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM