1

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.

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.