admin管理员组文章数量:1431037
I have a CPT defined in code called event, and there is a template file for the markup (single-event.php).
I am wondering if it is possible to override a post within the Event CPT with the Gutenberg block editor, instead of using the php template every-time, is this possible?
I would ideally like the template file to apply to all my CPT posts, except one or two of them, which will require much different display.
EDIT: I guess in a more generic sense I am looking for optional template functionality for a CPT. Ability to use the provided template, or ignore it and utilize the block editor with Gutenberg.
I have a CPT defined in code called event, and there is a template file for the markup (single-event.php).
I am wondering if it is possible to override a post within the Event CPT with the Gutenberg block editor, instead of using the php template every-time, is this possible?
I would ideally like the template file to apply to all my CPT posts, except one or two of them, which will require much different display.
EDIT: I guess in a more generic sense I am looking for optional template functionality for a CPT. Ability to use the provided template, or ignore it and utilize the block editor with Gutenberg.
Share Improve this question edited Jun 3, 2019 at 22:21 PressWord asked Jun 3, 2019 at 21:55 PressWordPressWord 112 bronze badges1 Answer
Reset to default 0Since 4.7 Custom Post Types have supported custom templates, just like Pages. So you could copy your theme's generic page template to a new template file, and add this to the top.
<?php
/*
Template Name: Block editor template
Template Post Type: my-post-type
*/
That will let you switch the template for your my-post-type
post to a template that looks and works just like a normal page.
本文标签: Can I override a CPT template on a per post basis with Gutenberg block editor
版权声明:本文标题:Can I override a CPT template on a per post basis with Gutenberg block editor? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745427590a2658186.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论