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

customization - Adding Page Attributes and Page Templates to Custom Post Type WP 4.7.3

programmeradmin2浏览0评论

I have created a custom post type with capability => 'page'. Why can I not or how do I add the Page Attributes/Page Templates meta box to the admin edit page?

Yeah, cheers Joe. I also found this out about 20 mins after posting the original question. So, as long as you have page_attributes on you simply allow your templates to be accessible by adding: Template Post Type: new_post_type_name under Template Name: your_template_name in your custom template!

I have created a custom post type with capability => 'page'. Why can I not or how do I add the Page Attributes/Page Templates meta box to the admin edit page?

Yeah, cheers Joe. I also found this out about 20 mins after posting the original question. So, as long as you have page_attributes on you simply allow your templates to be accessible by adding: Template Post Type: new_post_type_name under Template Name: your_template_name in your custom template!

Share Improve this question edited Apr 29, 2017 at 13:59 Harry Black asked Apr 26, 2017 at 19:50 Harry BlackHarry Black 111 silver badge3 bronze badges 1
  • 2 What does your register_post_type() call look like? Add that code to your question. There is an array of options for the supports argument. – jdm2112 Commented Apr 26, 2017 at 19:59
Add a comment  | 

2 Answers 2

Reset to default 1

Check out my answer to a similar post. Custom page type - template under page attributes?

You'll have to create a page template and make that available to your new custom post type.

You can't apply templates to custom post types. However if you want to style all your single custom post types in the same manner but different from other post types you could use the single-[posttype].php -> Template_Hierarchy

The reason this hasn't been implemented is because custom posts can be styled using the default wordpress hierarchy.

For example, if you create a post type called custom-post you can create a template called single-custom-post.php that only applies to those custom posts and archive-custom-post.php that applies to the archive page. You can even add page-{post-id}.php to create a template for one specific page.

发布评论

评论列表(0)

  1. 暂无评论