Opened 4 years ago
Last modified 3 years ago
#41737 new enhancement
Possibly redundant template files in the hierarchy
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Themes | Keywords: | close |
Focuses: | template | Cc: |
Description
Hi,
As I'm building https://forklor.github.io/wp-template-hierarchy/ (still a work in progress) and sifting through the source code, it looks like the following template files in the hierarchy may be redundant:
${subtype}.php
for attachments — is there a need for a template for a subtype without its associated${mime_type}
? Is there a use-case am I missing where a subtype may be associated with different mime types?
attachment.php
can be caught insingle-attachment.php
.
For the sake of simplifying WP's API surface, I am proposing deprecating these templates in a future version.
And as a related question (let me know if I should open a separate issue), to preserve symmetry with other post types and and pages, should a Custom Post Template set for an attachment not get priority before the other attachment templates?
(Please let me know if I misunderstood anything!)
Change History (3)
#3
in reply to:
↑ description
@
3 years ago
- Keywords close added
- Version trunk deleted
Replying to danburzo:
Is there a use-case am I missing where a subtype may be associated with different mime types?
It's rare, but yes this does happen. Mime types for Ogg files work like this, with video/ogg
and audio/ogg
.
attachment.php
can be caught insingle-attachment.php
.
Yeah, the attachment template hierarchy has gotten a bit messed up. Deprecating or removing this doesn't provide much benefit, so I'd be hesitant to deprecate it.
See #38160 for more attachment template hierarchy weirdness.
For convenience, here's where the relevant code is located:
And a few related issues I found:
page.php
instead ofsingle-....php
: https://core.trac.wordpress.org/ticket/33017In regards to Custom Post Templates to apply to single attachments, posts, and pages, maybe have a
get_custom_template()
method intemplate.php
that gets called intemplate-loader.php
beforeis_attachment()
/is_single()
/is_page()
?On the topic of deprecation, I salute the demise of
paged.php
— I could not wrap my head around how to use it :P.