Make WordPress Core

Opened 7 years ago

Last modified 4 years ago

#41773 new enhancement

Page Templates // Post Type Templates | Any Post Type?

Reported by: michaelecklund's profile michael.ecklund Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7
Component: Posts, Post Types Keywords: needs-patch reporter-feedback
Focuses: ui, administration, template Cc:

Description

If I add a template like this:

<?php
/*
Template Name: Full-width layout
*/

It seems to only be visible on the page Post Type in the meta box drop down.

If I add a template like this:

<?php
/*
Template Name: Full-width layout
Template Post Type: post, page, artist, album, track
*/

It's available in the meta box drop down for the specified Post Types.

I would like to add a template and have it available to all Post Types.

Perhaps add like this:

<?php
/*
Template Name: Full-width layout
Template Post Type: any
*/

Change History (3)

#1 @johnbillion
7 years ago

  • Keywords needs-patch reporter-feedback added
  • Version changed from 4.8.1 to 4.7

I thought some discussion around this had happened on #18375, but I can't immediately see it.

What's the real-world use-case for this?

#2 follow-up: @michael.ecklund
7 years ago

  • I would like to be able to control content and sidebar placement.
  • I'd rather not have 50 million static templates which are all essentially the same code.
  • I'd like the freedom and flexibility to change between: sidebar left, sidebar right, or no sidebar. No matter what type of content it is.

As a temporary solution I've been able to implement my template idea for all post types by looping all post types and using the hook: add_filter( "theme_{$post_type}_templates", "add_my_templates" );

Just seems like it would be a simple fix to add an "any" parameter. Much like WP_Query(); allows.

P.S. Why did you revert the version number from 4.8.1 to 4.7? I'm using 4.8.1 as reported.

#3 in reply to: ↑ 2 @SergeyBiryukov
7 years ago

Replying to michael.ecklund:

P.S. Why did you revert the version number from 4.8.1 to 4.7? I'm using 4.8.1 as reported.

The Version field indicates the earliest affected version, not the latest one.

Template Post Type header was introduced in [38951] for WordPress 4.7.

Note: See TracTickets for help on using tickets.