#12759 closed defect (bug) (fixed)
"Template" shouldn't show for custom hierarchical post types
Reported by: | greenshady | Owned by: | |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Description
When creating a custom post type that is hierarchical, the post type would likely support the page-attributes
meta box because this grants access to the parent drop-down.
While I can certainly see the benefit in having the ability to create custom templates, my "page" templates shouldn't appear for other post types. These templates were created for use specifically with the page post type.
I see four solutions for fixing this issue:
1) Remove this when the post type isn't a page.
2) Allow for specific post type templates to be recognized in the form of:
$post_type->singular_label Template: Example
3) Create a separate meta box that simply handles the parent so the page-attributes
meta box isn't needed.
4) Add a hook so developers can remove this.
Note that the page template drop-down is also shown with the quick edit feature.
Attachments (1)
Change History (14)
#2
@
15 years ago
As an extra note to this: Even if a "page" template is shown for non-page post types, it is neither saved nor used.
#4
@
14 years ago
Is this logic still valid w/ 3.0? Or rather, should custom post types be completely restricted to just one page template? CPT can function as pages (all the capabilities are there) so why shouldn't a cpt be able to have page-by-page templates?
#6
@
14 years ago
Is this logic still valid w/ 3.0?
This ticket and bug fix were made specifically for 3.0.
Or rather, should custom post types be completely restricted to just one page template? CPT can function as pages (all the capabilities are there) so why shouldn't a cpt be able to have page-by-page templates?
Custom post types should not use templates created for a different post type.
#7
@
14 years ago
- Cc elementweb added
- Resolution fixed deleted
- Status changed from closed to reopened
This seems a poor solution, as custom templates do not have to be reserved for page types. Before custom post types, they were indeed only used for page types, but that is only a matter of what the post type supports.
If a post type (whether by default, as for pages, or custom) supports page-attributes, there is no reason it should not allow for custom templates to be selected. Doing so basically tells the post type to behave like a page, and as such it should have all the functionality of a page.
This restricts functionality for the whole platform out of the personal preference of one or a few persons. It also contradicts the documentation (which should either be adjusted to reflect this decision, if the current proposal is deemed unacceptable).
It would be best to allow custom templates to be used when a post type has page attributes (so as not to arbitrarily restrict functionality) until a better choice is made, for example the addition of a restriction for custom templates.
Custom post types should not use templates created for a different post type.
This is particularly wrong as custom templates are not created specifically for pages, there is no such distinction other than the fact that before custom post types, it was their only use. Custom post types have changed this paradigm.
A rather "easy" fix would be to add an optional attribute to custom templates that either limits or restricts post types (by default either to "page" post type or to all). Although I do note that there are several changes necessary for this as page attributes are set to be saved in several places only for the "page" post type.
I have found that there are 2 distinct places to patch to allow the page template to be save, but there are other places to check as the meta box does not reload the selected page template (even though correctly saved in postmeta) and the page template is not loaded. Basically is_page() would come down to checking whether the post type supports page-attributes.
#8
@
14 years ago
I'm not sure why a custom template should only be available for pages. Most themes offer custom templates for things like "full width", "right sidebar", "three column", etc. Why wouldn't these be useful on certain post types?
I'd prefer to see an option added to custom post types that allows them to use custom templates. However, for now I'd either like to see [14642] or this ticket punted to early 3.2...let's get 3.1 out the door :)
#10
@
14 years ago
- Resolution set to fixed
- Status changed from reopened to closed
This ticket was closed on a completed milestone. New ticket, please.
This ticket was mentioned in Slack in #themereview by karmatosed. View the logs.
10 years ago
#12
@
10 years ago
- Keywords dev-feedback needs-patch needs-refresh added; has-patch removed
- Severity changed from normal to critical
- Type changed from defect (bug) to feature request
- Version 3.0 deleted
This needs to be reviewed again, it would be nice to have different templates for other post types including post. I have a need for posts to have different templates specified by author. Either this needs implemented or the functionality of adding new post formats needs implemented.
It's very much a pain to have to work around this with advanced custom fields.
#13
@
10 years ago
- Keywords has-patch added; dev-feedback needs-patch needs-refresh removed
- Severity changed from critical to normal
- Type changed from feature request to defect (bug)
- Version set to 3.0
This ticket was fixed and closed on a completed milestone. It was meant to fix a bug in WordPress and has little-to-no relevance to being able to create custom templates for CPTs (which is easy to do, by the way).
Please open a new ticket for enhancements.
Don't show the template dropdown for non-page post types.