[wp-trac] [WordPress Trac] #38160: Attachment template hierarchy selects generic attachment.php before specific post type templates

WordPress Trac noreply at wordpress.org
Mon Sep 26 13:29:01 UTC 2016


#38160: Attachment template hierarchy selects generic attachment.php before
specific post type templates
-------------------------+------------------------------------------
 Reporter:  johnbillion  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Themes       |    Version:
 Severity:  normal       |   Keywords:  needs-patch needs-unit-tests
  Focuses:  template     |
-------------------------+------------------------------------------
 When viewing a single attachment at its permalink, the template hierarchy
 is as follows (using `foo.jpg` as an example).

 1. `image-jpeg.php`
 2. `jpeg.php`
 3. `image.php`
 4. `attachment.php`
 5. `single-attachment-foo.php`
 6. `single-attachment.php`
 7. `single.php`
 8. `singular.php`
 9. `index.php`

 Note that the generic `attachment.php` appears higher in the hierarchy
 than the more specific `single-attachment-foo.php`. This means it's
 impossible to target a specific attachment if an `attachment.php` file is
 in place.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38160>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list