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
Allow themes to add custom templates description #44097
Comments
Hi, |
Thanks, @talldan, for removing the stale tag. I still think it'd be helpful for both themers and users if we could add descriptions to custom templates. |
As we see more work happening on the Site Editor view, it would be great to see these descriptions added to help with consistency in the Template view. Further, the ability to easily create templates within the admin means users may add more templates than they have historically. Having a way to describe these templates for themselves and other users will be a necessity. |
Core doesn't allow custom template descriptions via `theme.json`, so these must be added via PHP. See: WordPress/gutenberg#44097
Actually after investigating this a bit more the So you can add your custom templates including description like so: add_filter( 'default_template_types', 'add_custom_template_types', 10, 1 );
/**
* Add custom template types.
*
* @param array $templates The default template types.
*
* @return array The modified template types.
*/
function add_custom_template_types( $templates ) {
$templates['single-podcast'] = [
'title' => __( 'Single Podcast', 'namespace' ),
'description' => __( 'A single podcast post.', 'namespace' ),
];
return $templates;
} |
Themes can add custom templates, but there doesn't seem to be a way to add descriptions. @jffng kindly looked into this for me, and it seemed like
name
,title
, andpostTypes
are allowed at the moment.gutenberg/schemas/json/theme.json
Line 1559 in 40efcbe
The screenshot was from a site with Twenty Twenty-Two, but many other themes also have no way of clarifying the custom template. The description will help theme builders to communicate with the user what the custom templates are for.
I've briefly looked for a request opened before but couldn't find it. If there is somewhere, kindly point me to the conversation. Thanks in advance!
The text was updated successfully, but these errors were encountered: