#21268 closed defect (bug) (duplicate)
_wp_page_template is getting 'stuck' to a page
Reported by: | shawmutsteve | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 3.4.1 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | administration | Cc: |
Description
Unmodified WP 3.4.1 / Ummodified TwentyEleven theme
Create a page (id=2). Manually add a postmeta entry for
post_id=2, meta_key = _wp_page_template, meta_value = pagefull.php
The page now opens with margin: 0 7.6%; (correct!)
Now try to change it back to default, either by removing the _wp_page_template postmeta record or by editing the page -> Page Attribute / Template. The page will not revert back to Default. It continually displays as Full Width, and a postmeta item telling post_id 2 to use _wp_page_template = pagefull.php is added.
http://wp34.roveridx.com/?page_id=2
This behavior does not happen in 3.3.2.
Change History (7)
#2
in reply to:
↑ description
@
11 years ago
This could be solved by changing the following line of code on line 659 in file 'wp-admin/includes/meta-boxes.php'
if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) {
to
if ( 'page' == $post->post_type ) {
This would always cause a dropdown to be displayed in the Page Attributes Meta Box even if "Default Template" is the only page template option.
This could be a very frustrating experience for a new Wordpress user, who, after switching themes, will no longer be able to update their post_meta fields because their page template is "stuck" on some other themes page template.
Consider this bit of code in 'wp-includes/post.php'. The code will fail when checking for a valid page template, and never run the function, update_post_meta(); So plugins like Yoast SEO or any other using custom meta fields will not be able to save new inputs.
if ( !empty($page_template) && 'page' == $data['post_type'] ) { $post->page_template = $page_template; $page_templates = wp_get_theme()->get_page_templates(); if ( 'default' != $page_template && ! isset( $page_templates[ $page_template ] ) ) { if ( $wp_error ) return new WP_Error('invalid_page_template', __('The page template is invalid.')); else return 0; } update_post_meta($post_ID, '_wp_page_template', $page_template); }
I hope this is helpful for someone and that this problem can get solved.
Replying to shawmutsteve:
Unmodified WP 3.4.1 / Ummodified TwentyEleven theme
Create a page (id=2). Manually add a postmeta entry for
post_id=2, meta_key = _wp_page_template, meta_value = pagefull.phpThe page now opens with margin: 0 7.6%; (correct!)
Now try to change it back to default, either by removing the _wp_page_template postmeta record or by editing the page -> Page Attribute / Template. The page will not revert back to Default. It continually displays as Full Width, and a postmeta item telling post_id 2 to use _wp_page_template = pagefull.php is added.
http://wp34.roveridx.com/?page_id=2
This behavior does not happen in 3.3.2.
#3
@
11 years ago
- Component changed from General to Administration
- Keywords needs-patch added
- Severity changed from normal to major
#4
@
11 years ago
- Keywords close added; needs-patch removed
- Severity changed from major to minor
Thanks for the report. I can't reproduce this in later versions of WordPress — can you please upgrade to 3.7 and let update this ticket if you're still having that problem?
This could be solved by changing the following line of code on line 659 in file 'wp-admin/includes/meta-boxes.php'
to
This would always cause a dropdown to be displayed in the Page Attributes Meta Box even if "Default Template" is the only page template option.
This could be a very frustrating experience for a new Wordpress user, who, after switching themes, will no longer be able to update their post_meta fields because their page template is "stuck" on some other themes page template.
Consider this bit of code in 'wp-includes/post.php'. The code will fail when checking for a valid page template, and never run the function, update_post_meta(); So plugins like Yoast SEO or any other using custom meta fields will not be able to save new inputs.
I hope this is helpful for someone and that this problem can get solved.