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

How to add a template via a plugin (podcast, woo, LMS) #189

Closed
bph opened this issue Dec 19, 2023 Discussed in #185 · 17 comments
Closed

How to add a template via a plugin (podcast, woo, LMS) #189

bph opened this issue Dec 19, 2023 Discussed in #185 · 17 comments
Assignees

Comments

@bph
Copy link
Collaborator

bph commented Dec 19, 2023

Discussed in #185

Originally posted by bph December 14, 2023
This question came up quite a bit in the last few months. Example
It might not be possible, as I still see this issue open: Add support for adding templates and template parts for plugins #42362

So this is more a placeholder Topic idea, when this is worked out in core.

@bph bph added flow: needs writer the idea/pitch needs a writer flow: needs input let's discuss this. flow: approved can move forward Building Blocks plugin development labels Dec 19, 2023
@bph
Copy link
Collaborator Author

bph commented Dec 19, 2023

This is the original issue WordPress/gutenberg#41401

@petrio-seo

This comment was marked as spam.

@justintadlock
Copy link

I have a solution for this: https://gist.github.com/justintadlock/cfcdcdf47ea785e84c8575dddc68ea37

There are several possibilities that could be explored based on the code in that Gist. It's specific to virtual pages, which is what I'm assuming is the biggest pain-point. But there are things that plugins can do now to make their "regular, non-virtual" templates editable in a block theme.

Anyone is welcome to take this code and run with it. I don't know what kind of bandwidth I'll have to fit another tutorial into my schedule in the immediate future, so I'll leave this topic unclaimed. But if no one picks it up, I'm OK with adding it to my list after the WP 6.5 update is out.

@justintadlock
Copy link

Just an update from my end: I still have #238 and #239 to work through over the next few weeks. After that, I'm happy to take this one on. It might be mid-to-late April. But I'll leave this unassigned in case someone wants to try their hand at it.

@bph bph removed the flow: needs writer the idea/pitch needs a writer label Mar 26, 2024
@annezazu
Copy link

annezazu commented Jun 6, 2024

Chiming in here that this PR is very much underway: WordPress/gutenberg#61577

@bph
Copy link
Collaborator Author

bph commented Jul 31, 2024

It seems the PR is about to be merged

@justintadlock
Copy link

@Aljullu
Copy link

Aljullu commented Aug 19, 2024

That's really cool, @justintadlock! Thanks for working on this. I see you used the .php extension for template files, is there any benefit of doing so instead of .html?

@justintadlock
Copy link

@Aljullu - Because the files have PHP code in them for things like internationalization. This is pretty typical when building default templates.

@Aljullu
Copy link

Aljullu commented Aug 19, 2024

@Aljullu - Because the files have PHP code in them for things like internationalization. This is pretty typical when building default templates.

Oh, right, I missed the PHP snippets in some of them. It makes sense. 👍

@justintadlock
Copy link

This one is ready for its first review: https://docs.google.com/document/d/1df9U3h5umMpbIEXRp4K38F9oFXDRPAi_4VPvt0houGg/edit?usp=sharing

@Aljullu - Any technical feedback you'd like to share is more than welcome as well.

Note: If testing code, this requires Gutenberg 19.1. Also, the post cannot be published until that version of Gutenberg is live.

@Aljullu
Copy link

Aljullu commented Aug 23, 2024

I didn't test the code examples, but I read through it and everything looks good. Thanks for writing it, @justintadlock!

@ndiego
Copy link
Member

ndiego commented Aug 23, 2024

@justintadlock I completed the first review of the article and added a few comments. Looks great.

@justintadlock
Copy link

Moving this to second review.

We still have a couple of comments from the first review waiting for clarification/feedback in this ticket: WordPress/gutenberg#61577

@bph
Copy link
Collaborator Author

bph commented Aug 28, 2024

Finished second review. Just tiny little nitpicks. It's ready to publish

@justintadlock
Copy link

Social copy:

Coming in WordPress 6.7: Learn how to register block templates for plugin's custom post types, custom URLs, and more in this Developer Blog tutorial:

https://developer.wordpress.org/news/2024/08/29/registering-block-templates-via-plugins-in-wordpress-6-7/

@justintadlock
Copy link

Social post scheduled for September 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Published (Done)
Development

No branches or pull requests

6 participants