Make WordPress Core

Opened 12 years ago

Closed 8 years ago

Last modified 8 years ago

#18859 closed enhancement (fixed)

Single theme template for custom post by slug

Reported by: ericjuden's profile ericjuden Owned by: sergeybiryukov's profile 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 11 years ago.
18859.patch (389 bytes) - added by ocean90 11 years ago.
Relative path.
18859.2.patch (368 bytes) - added by ericjuden 11 years ago.
Function has moved to template.php
18859.3.patch (401 bytes) - added by SergeyBiryukov 11 years ago.
Relative path, proper formatting
18859.4.patch (491 bytes) - added by ericjuden 10 years ago.
Updated for 3.5
18859.5.patch (759 bytes) - added by johnbillion 8 years ago.

Download all attachments as: .zip

Change History (17)

#1 @chipbennett
12 years ago

  • Keywords needs-testing added

11 years ago


11 years ago

Relative path.

#2 @ocean90
11 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
11 years ago

  • Version changed from 3.3 to 3.4

#4 @SergeyBiryukov
11 years ago

  • Version changed from 3.4 to 3.3

Version field indicates when the enhancement was initially suggested.

#5 @johnbillion
11 years ago

  • Cc johnbillion added

11 years ago

Function has moved to template.php

#6 @ericjuden
11 years ago

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

11 years ago

Relative path, proper formatting

10 years ago

Updated for 3.5

#7 @sc0ttkclark
10 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
9 years ago

  • Component changed from Template to Themes
  • Focuses template added

8 years ago

#9 @johnbillion
8 years ago

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

It shall be done.

#10 @SergeyBiryukov
8 years 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
8 years ago

Thanks guys! Glad it finally made it in.


Note: See TracTickets for help on using tickets.