WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.55k stars 4.22k forks source link

Post formats: Archive templates have no description and use the slug instead of a readable name #65319

Open carolinan opened 2 months ago

carolinan commented 2 months ago

Description

When a block theme includes the HTML file for a post format archive, the Site Editor and Data Views shows the template without a description and without a human-readable name. Instead it uses the slug, name from the HTML file.

It is as if the Data Views do not recognise that the template is part of the template hierachy.

Step-by-step reproduction instructions

First, you need a block theme, and you need to enable post format support on the active theme.

Example:

function twentytwentyfour_setup(){
    add_theme_support( 'post-formats', array( 'standard', 'aside', 'gallery', 'audio', 'video', 'link', 'image', 'chat', 'status', 'quote' ) );
}

add_action( 'after_setup_theme', 'twentytwentyfour_setup' );

Next, add a post format archive template inside the templates folder. The content of the file does not matter for this test. I have used the link post format as example: templates/taxonomy-post_format-post-format-link.html

Optionally, create one or more posts with the link post format assigned.

Go to Appearance > Editor > Templates. Note that the link archive is available, but uses the whole slug as the template name.

Screenshots, screen recording, code snippet

The link post format archive template on the Template screen, showing the partial file name for the template.

Environment info

WordPress 6.6.2, with and without Gutenberg trunk.

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

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

carolinan commented 2 months ago

TLDR: It seems the data for this template does not exist in the entity records.

t-hamano commented 2 months ago

The title and description of the default templates are defined in the core: https://github.com/WordPress/wordpress-develop/blob/a78540b0881a195ec8488bb6bdf878114d75f8b8/src/wp-includes/block-template-utils.php#L141

Therefore, it may be a good idea to submit a core ticket.

By the way, you can change the title and description by using the default_template_types filter hook:

function twentytwentyfour_add_default_template( $default_template_types ) {
    $default_template_types['taxonomy-post_format-post-format-link'] = array(
        'title'       => __( 'Link Post Format' ),
        'description' => __( 'Description.' ),
    );
    return $default_template_types;
}
add_action( 'default_template_types', 'twentytwentyfour_add_default_template' );

This hook is not only reflected in the DataViews, but also in the template sidebar, for example:

image

carolinan commented 2 months ago

Thank you!

carolinan commented 3 weeks ago

Adding a link to the core ticket and PR meanwhile: https://core.trac.wordpress.org/ticket/62326