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

Nicer UX with custom template part areas #125

Closed bph closed 1 year ago

bph commented 1 year ago

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

Originally posted by **justintadlock** May 19, 2023 By default, there are 3 template part areas that themes can use: - Header - Footer - Uncategorized In early development, there was once also a Sidebar area, but it was removed. Theme authors can register any custom areas they want via the `default_wp_template_part_areas` filter hook. This has been around for a while but is undocumented (AFAIK). This would be a super simple tutorial to write (_would make for a "good first topic" for a new Dev Blog writer_): PoC of registering a sidebar area: ```php add_filter( 'default_wp_template_part_areas', function( $areas ) { $areas[] = [ 'area' => 'sidebar', 'label' => __( 'Sidebar', 'themeslug' ), 'description' => __( 'Custom description', 'themslug' ), 'icon' => 'layout', 'area_tag' => 'div' ]; return $areas; } ); ``` This makes navigating the template editor UI much nicer. For example, in this screenshot, the area is labeled "Sidebar" instead of "General": ![image](https://github.com/WordPress/developer-blog-content/assets/1816309/c97d6f04-cac3-4de0-b577-45ed794a78bd)
justintadlock commented 1 year ago

The first draft of this post is now ready for review via Google Docs: https://docs.google.com/document/d/1GU6bX3BeigntybZBtlN69qqvZdenTwNSAZPW23G9XNQ/edit?usp=sharing

justintadlock commented 1 year ago

Thanks, @marybaum, for the first review. This reads much better now!

bph commented 1 year ago

Pre and post publishing checklist:

justintadlock commented 1 year ago

Post published here: https://developer.wordpress.org/news/2023/06/upgrading-the-site-editing-experience-with-custom-template-part-areas/