#13272 closed defect (bug) (duplicate)
Custom post types not loading custom templates from admin page
Reported by: | beekado | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
I've been trying to assign custom templates with custom post types supporting 'page-attributes'. From the front end, creating single-xxx.php (xxx = custom post type) works, but from the backend the dropdown always shows "Default Template" even though the other custom template is in the list.
I checked the DB and _wp_page_template is not being saved in wp_postmeta for a custom post. After I manually added an entry in the table, it was still not showing up. This must be due to the following in wp-admin/includes/post.php:
function get_post_to_edit( $id ) {
$post = get_post( $id, OBJECT, 'edit' );
if ( $post->post_type == 'page' )
$post->page_template = get_post_meta( $id, '_wp_page_template', true );
return $post;
}
By commenting 'if ( $post->post_type == 'page' )' the template is now picked up. However, when trying to update it the value in the dropdown does not change (did not investigate updates yet)
Another thing I also noticed is that after doing the above, the template is not chosen on the front end unless the page name starts with single-[something].php
I'm not sure if this is supposed to happen or not, but some plugins like MultiEdit rely on the value in the admin dropdown to function properly.
Let me know if the above makes sense.
See #12759 as the original ticket dealing with this.