Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP_Post_Type->template is not used in site editor #60710

Closed
bacoords opened this issue Apr 12, 2024 · 3 comments · Fixed by #62488
Closed

WP_Post_Type->template is not used in site editor #60710

bacoords opened this issue Apr 12, 2024 · 3 comments · Fixed by #62488
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@bacoords
Copy link
Contributor

bacoords commented Apr 12, 2024

Description

The initial state of a new post type is defined in WP_Post_Type->template. This initial state is acknowledged by the block editor when creating a new post/page/etc but not in the site editor.

Step-by-step reproduction instructions

  1. Register a post type block template for a post type that appears in the site editor. We'll usepage (but you could use wp_block). Place this in a functions.php or plugin file:
function myplugin_register_template() {
    $post_type_object = get_post_type_object( 'page' );
    $post_type_object->template = array(
        array( 'core/image' ),
    );
}
add_action( 'init', 'myplugin_register_template' );
  1. Start a new page from the regular dashboard, which loads the block editor, and you'll see the initial block content (an image block) in the post content.
  2. Start a new page from inside the site editor - you'll see that there is no initial block content.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.5.2
  • Gutenberg 18.1.0

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@bacoords bacoords added the [Type] Bug An existing feature does not function as intended label Apr 12, 2024
@youknowriad youknowriad added the [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") label Apr 12, 2024
@colorful-tones
Copy link
Member

I'm a bit confused about the expectations and testing steps here and how they correlate to a bug.

Currently, I do not expect that I should be able to register a new custom post type, and be able to edit it in the Site Editor. This is not to say that there should never be considerations and planning to support custom post types in the Site Editor, and I would certainly expect it with the direction things are heading.

The referenced (Block) Templates handbook page also states the following:

Planned additions:

  • Saved and assigned to pages as “page templates”.
  • Defined in a template.php file or pulled from a custom post type (wp_templates) that is site specific.
  • As the equivalent of the theme hierarchy.

Ultimately, I'm glad an issue captures this and it should be explored at some point.

@bacoords
Copy link
Contributor Author

Thanks for looking! @colorful-tones I updated the instructions with a clear code snippet to make testing and the overall expectations more clear. This currently effects post types that already can be created in the site editor: page and wp_block (patterns),

@fabiankaegy
Copy link
Member

I can replicate this 👍 This will be very important to fix before we ever support the creation/editing of other content types because the template field is much more used on custom post types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
5 participants