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.