Make WordPress Core

Opened 4 years ago

Closed 2 months ago

Last modified 7 weeks ago

#18859 closed enhancement (fixed)

Single theme template for custom post by slug

Reported by: ericjuden Owned by: SergeyBiryukov
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.3
Component: Themes Keywords: has-patch commit
Focuses: template Cc:


I was working on adding a custom template for an individual post in my custom post type and discovered that you could only make a single-{post-type}.php. This patch adds the ability to make single-{post-type}-{slug}.php

It's pretty straight forward, and only adds 1 line of code to wp-includes/theme.php

Attachments (6)

wp-includes-theme.php.patch (358 bytes) - added by ericjuden 4 years ago.
18859.patch (389 bytes) - added by ocean90 4 years ago.
Relative path.
18859.2.patch (368 bytes) - added by ericjuden 3 years ago.
Function has moved to template.php
18859.3.patch (401 bytes) - added by SergeyBiryukov 3 years ago.
Relative path, proper formatting
18859.4.patch (491 bytes) - added by ericjuden 3 years ago.
Updated for 3.5
18859.5.patch (759 bytes) - added by johnbillion 2 months ago.

Download all attachments as: .zip

Change History (17)

#1 @chipbennett
4 years ago

  • Keywords needs-testing added

4 years ago


4 years ago

Relative path.

#2 @ocean90
4 years ago

  • Component changed from Post Types to Template
  • Keywords dev-feedback added; needs-testing removed

+1 from me.

Pages and Taxonomies are supporting slugs.

#3 @ericjuden
4 years ago

  • Version changed from 3.3 to 3.4

#4 @SergeyBiryukov
4 years ago

  • Version changed from 3.4 to 3.3

Version field indicates when the enhancement was initially suggested.

#5 @johnbillion
4 years ago

  • Cc johnbillion added

3 years ago

Function has moved to template.php

#6 @ericjuden
3 years ago

I just updated the patch. The get_single_template() function was moved into wp-includes/template.php as of WordPress 3.4.

3 years ago

Relative path, proper formatting

3 years ago

Updated for 3.5

#7 @sc0ttkclark
3 years ago

  • Cc lol@… added

I'd like this as well, or at the very least {post_type}-{slug}.php like pages get.

#8 @nacin
22 months ago

  • Component changed from Template to Themes
  • Focuses template added

#9 @johnbillion
2 months ago

  • Keywords commit added; dev-feedback removed
  • Milestone changed from Awaiting Review to 4.4

It shall be done.

#10 @SergeyBiryukov
2 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 34800:

Add single-{post_type}-{post_name}.php to the top of the template hierarchy for single posts.

This is consistent with page and taxonomy templates, which support slugs as well.

Props ericjuden, johnbillion.
Fixes #18859.

#11 @ericjuden
7 weeks ago

Thanks guys! Glad it finally made it in.


Note: See TracTickets for help on using tickets.