Make WordPress Core

Opened 13 years ago

Closed 9 years ago

Last modified 9 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:

Description

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 13 years ago.
wp-includes-theme.php.patch
18859.patch (389 bytes) - added by ocean90 13 years ago.
Relative path.
18859.2.patch (368 bytes) - added by ericjuden 12 years ago.
Function has moved to template.php
18859.3.patch (401 bytes) - added by SergeyBiryukov 12 years ago.
Relative path, proper formatting
18859.4.patch (491 bytes) - added by ericjuden 12 years ago.
Updated for 3.5
18859.5.patch (759 bytes) - added by johnbillion 9 years ago.

Download all attachments as: .zip

Change History (17)

#1 @chipbennett
13 years ago

  • Keywords needs-testing added

@ericjuden
13 years ago

wp-includes-theme.php.patch

@ocean90
13 years ago

Relative path.

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

  • Version changed from 3.3 to 3.4

#4 @SergeyBiryukov
13 years ago

  • Version changed from 3.4 to 3.3

Version field indicates when the enhancement was initially suggested.

#5 @johnbillion
13 years ago

  • Cc johnbillion added

@ericjuden
12 years ago

Function has moved to template.php

#6 @ericjuden
12 years ago

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

@SergeyBiryukov
12 years ago

Relative path, proper formatting

@ericjuden
12 years ago

Updated for 3.5

#7 @sc0ttkclark
12 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
11 years ago

  • Component changed from Template to Themes
  • Focuses template added

@johnbillion
9 years ago

#9 @johnbillion
9 years ago

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

It shall be done.

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

Thanks guys! Glad it finally made it in.

Eric

Note: See TracTickets for help on using tickets.