Opened 7 years ago
Closed 2 years ago
#41737 closed enhancement (wontfix)
Possibly redundant template files in the hierarchy
Reported by: | danburzo | Owned by: | |
---|---|---|---|
Milestone: | 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 (4)
#3
in reply to:
↑ description
;
follow-up:
↓ 4
@
7 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.
#4
in reply to:
↑ 3
@
2 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
I agree with johnbillion's hesitation:
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.
as well as John's reasoning for closing #38160:
It would be nice to fix this but there's no sign of any demand for it.
I too think there's not enough benefits to outweigh the impacts of deprecating. If however enough benefits do surface, this could be reopened for consideration.
Thank you @danburzo for opening this ticket and contributing!
For convenience, here's where the relevant code is located:
And a few related issues I found:
page.php
instead ofsingle-....php
: #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.