1 | | This could be solved by changing the following line of code on line 659 in file 'wp-admin/includes/meta-boxes.php' |
2 | | |
3 | | {{{ |
4 | | if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) { |
5 | | }}} |
6 | | to |
7 | | {{{ |
8 | | if ( 'page' == $post->post_type ) { |
9 | | }}} |
10 | | |
11 | | 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. |
12 | | |
13 | | [[Image(http://webplantmedia.com/assets/Screen-Shot-2013-10-11-at-2.06.27-AM.jpg)]] |
14 | | |
15 | | 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. |
16 | | |
17 | | 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. |
18 | | |
19 | | {{{ |
20 | | if ( !empty($page_template) && 'page' == $data['post_type'] ) { |
21 | | $post->page_template = $page_template; |
22 | | $page_templates = wp_get_theme()->get_page_templates(); |
23 | | if ( 'default' != $page_template && ! isset( $page_templates[ $page_template ] ) ) { |
24 | | if ( $wp_error ) |
25 | | return new WP_Error('invalid_page_template', __('The page template is invalid.')); |
26 | | else |
27 | | return 0; |
28 | | } |
29 | | update_post_meta($post_ID, '_wp_page_template', $page_template); |
30 | | } |
31 | | }}} |
32 | | |
33 | | I hope this is helpful for someone and that this problem can get solved. |
34 | | |
35 | | Replying to [ticket:21268 shawmutsteve]: |
36 | | > Unmodified WP 3.4.1 / Ummodified TwentyEleven theme |
37 | | > |
38 | | > Create a page (id=2). Manually add a postmeta entry for |
39 | | > |
40 | | > {{{ |
41 | | > post_id=2, |
42 | | > meta_key = _wp_page_template, |
43 | | > meta_value = pagefull.php |
44 | | > }}} |
45 | | > |
46 | | > |
47 | | > The page now opens with margin: 0 7.6%; (correct!) |
48 | | > |
49 | | > 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. |
50 | | > |
51 | | > http://wp34.roveridx.com/?page_id=2 |
52 | | > |
53 | | > This behavior does not happen in 3.3.2. |