简体   繁体   中英

Wordpress custom post permalink template

I got a new posttype called "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.

Can anyone help me?

Edit 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.

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.

These types of pages that list all posts are referred to as 'archive' pages, so instead try editing archive-butik.php

single.php displays one single post. Chances are the url doesn't specify an individual post.

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.

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