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

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

Open
2 tasks done
carolinan opened this issue Sep 13, 2024 · 4 comments
Open
2 tasks done
Assignees
Labels
[Package] DataViews /packages/dataviews [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

carolinan commented Sep 13, 2024

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.

  • Yes

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

  • Yes
@carolinan carolinan added [Type] Bug An existing feature does not function as intended [Package] DataViews /packages/dataviews labels Sep 13, 2024
@carolinan
Copy link
Contributor Author

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

@t-hamano
Copy link
Contributor

t-hamano commented Sep 13, 2024

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
Copy link
Contributor Author

Thank you!

@carolinan
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] DataViews /packages/dataviews [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants