WordPress / developer-blog-content

In this GitHub space, WordPress team coordinate content to be published on the Developer Blog. Discussion and montly meetings (first Thu) in WP Slack #core-dev-blog
36 stars 2 forks source link

Classic themes: tutorial on moving away from widgets to template parts #259

Open bph opened 2 months ago

bph commented 2 months ago

Discussed in https://github.com/WordPress/developer-blog-content/discussions/254

Originally posted by **annezazu** April 25, 2024 Pulling out of [this GitHub issue](https://github.com/WordPress/gutenberg/issues/26170#top) and thinking about the future of patterns & template parts, [including exposing patterns for classic themes in 6.6](https://github.com/WordPress/gutenberg/issues/52150), I think we need a blog post talking about how classic theme authors [should move to include template parts](https://learn.wordpress.org/tutorial/using-block-template-parts-in-classic-themes/) instead of adding entity based blocks to widget sidebars. I'd see this as a part tutorial and part announcement/encouragement. I think a lot of material could be reused and it could include information about the future of exposing patterns and why that's a more viable pathway with classic themes, including for template parts.
bacoords commented 1 month ago

👋 I'd be interested

justintadlock commented 1 month ago

@bacoords - Glad to have you here and volunteering for this post. I'm also excited to see what you come up with. Feel free to ask me for any help or anyone from the #core-dev-blog Slack channel about getting started.

Here's a list with important links for contributing:

The biggest thing is to put your draft (when you start it) in a Google Doc that has open comments/suggestions and leave the link to it here. The review process will happen within the doc.

bacoords commented 1 month ago

Here's a link to the Google doc for this article. As of right now there's just a rough outline to show what I plan to cover and the examples I'm hoping to include. I'll be working on fleshing this out a bit more throughout the week and turning it into an initial draft.

https://docs.google.com/document/d/1h4ED2l__6Hq9hMEIuDJn1oeo8IvMsTuBjgFNGzLknn8/edit?usp=sharing

bph commented 4 weeks ago

Hi there @bacoords - I was wondering what your timeline is to work on your article.

bacoords commented 4 weeks ago

Hey @bph - actually do you mind just opening the initial outline and making sure it tracks with your team's concept for this article?

MadtownLems commented 4 weeks ago

We've long wanted to move from Widgets to Template Parts, but one of our biggest hangups is that our theme's primary widget area (footer) has a black background, where page/post content has a white background. I would hope that a tutorial that talks about switching can help us figure out how to best handle that in a way where editing the Template Part is done in a way that reflects how things will look on the front end.

bph commented 3 weeks ago

@bacoords The outline is great....

There is a previous article on the developer blog: Upgrading the site-editing experience with custom template part areas. I just mention it here so it can be added to a resource list... don't remember if that also applies to classic themes

bacoords commented 3 weeks ago

I would hope that a tutorial that talks about switching can help us figure out how to best handle that in a way where editing the Template Part is done in a way that reflects how things will look on the front end.

While I can think of some approaches for applying styles to the block editor based on a specific instance, I don't know if that'll fit into the scope of this particular article. It would probably need to be it's on article. Mainly because there's not a simple way to do it, you would have to enqueue stylesheets to the block editor, etc.

If I see some simple approach that I'm missing while I research/write this, then I'll definitely include it.

justintadlock commented 3 weeks ago

I use a custom block style variation for those sort of large sections. For example, here's a "Site Footer" style variation in my theme:

image

It's not an ideal method IMO since it's a one-off thing, but it's at least one approach. I feel like this could be outside the scope of the primary topic. Maybe a minor note, at best. But I'll leave that up to Brian.