WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#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.

Change History (4)

comment:1 @greenshady5 years ago

See #12759 as the original ticket dealing with this.

comment:2 @beekado5 years ago

Thanks

comment:3 @hakre4 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #12759 , should be fixed.

comment:4 @nacin4 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.