Make WordPress Core

Opened 11 years ago

Last modified 6 years ago

#27425 new enhancement

Templates For Posts Formats

Reported by: hardeepasrani's profile hardeepasrani Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Post Formats Keywords: dev-feedback needs-patch
Focuses: template Cc:

Description

If I opt to use Custom Post Templates, then I can easily put a custom post template by putting a file named single-[name of the custom post], but that same feature is not available for the post formats.

I love the post format feature in WordPress, and people just don't want to use that for some reasons, but this would really attract some of the audience to use the post formats.

For example, a post with Audio format will first look for single-audio.php or single-audioformat.php or anything cuz it single-audio.php may effect the Audio Custom post type.

What do you guys think of this idea?

Change History (6)

#1 @hardeepasrani
11 years ago

Anyone looking forward to review this ticket of mine?

#2 follow-up: @SergeyBiryukov
11 years ago

A workaround:

function use_post_format_templates_27425( $template ) {
	if ( is_single() && has_post_format() ) {
		$post_format_template = locate_template( 'single-' . get_post_format() . '.php' );
		if ( $post_format_template ) {
			$template = $post_format_template;
		}
	}

	return $template;
}	
add_filter( 'template_include', 'use_post_format_templates_27425' );
Last edited 11 years ago by SergeyBiryukov (previous) (diff)

#3 in reply to: ↑ 2 @hardeepasrani
11 years ago

Replying to SergeyBiryukov:

A workaround:

function use_post_format_templates_27425( $template ) {
	if ( is_single() && has_post_format() ) {
		$post_format_template = locate_template( 'single-' . get_post_format() . '.php' );
		if ( $post_format_template ) {
			$template = $post_format_template;
		}
	}

	return $template;
}	
add_filter( 'template_include', 'use_post_format_templates_27425' );

I know this trick, but a feature like this should be in the core. I love formats option & people do some great stuff with it.

#4 @hardeepasrani
11 years ago

Will be continue to this ticker or shall I mark this as wontfix or closed?

#5 @hardeepasrani
10 years ago

  • Keywords dev-feedback added

#6 @chriscct7
9 years ago

  • Keywords needs-patch added
Note: See TracTickets for help on using tickets.