[wp-trac] [WordPress Trac] #41665: Theme Parent Templates Missing From Metabox: page-attributes

WordPress Trac noreply at wordpress.org
Thu Aug 17 20:09:09 UTC 2017


#41665: Theme Parent Templates Missing From Metabox: page-attributes
--------------------------------+-----------------------------
 Reporter:  michael.ecklund     |      Owner:
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Themes              |    Version:  4.8.1
 Severity:  normal              |   Keywords:
  Focuses:  ui, administration  |
--------------------------------+-----------------------------
 I have two themes.

 Parent Theme and Child Theme.

 Child Theme is the active theme.

 As per the Theme Developer Handbook,
 [https://developer.wordpress.org/themes/template-files-section/page-
 template-files/#creating-custom-page-templates-for-global-use Creating
 Custom Page Templates for Global Use].

 I've defined a simple page template to be used globally like so:

 {{{#!php
 <?php

 /**
  * Template Name: One Column
  */

 // ....

 ?>
 }}}


 The above code is placed into a file called `one-column.php` and for
 simplicity, placed into the theme root directory of the parent theme.

 When I edit a page in the backend, the `page-attributes` metabox has no
 option for a drop down menu at all. Yet, clearly I have a page template
 defined in the parent theme. It should be showing up, shouldn't it?

 Now... If I take the same exact page template file and move it into the
 root directory of the active child theme, and edit a page in the backend,
 the `page-attributes` metabox suddenly has a dropdown menu containing my
 page template (as expected).

 My question is, why are page templates defined in the parent theme of the
 active child theme completely ignored?

 Now to further test my point even more. Leave the `one-column.php` file in
 the root directory of the active child theme and add another page template
 file called `two-columns.php` and place this file into the root directory
 of the parent theme.

 Contents of `two-columns.php`:

 {{{#!php
 <?php

 /**
  * Template Name: Two Columns
  */

 // ....

 ?>
 }}}

 Edit a page, and take a gander at the dropdown menu in the `page-
 attributes` metabox. You will only see the page template of "One Column"
 as defined by `one-column.php` in the root directory of the active child
 theme. You will not see "Two Columns" as defined by `two-columns.php`
 defined in the root directory of the parent theme.


 ----

 '''Potential Start on Tracing/Debugging:'''

 `./wp-admin/includes/meta-boxes.php` '''Line 865'''
 `./wp-admin/includes/template.php` '''Line 771'''
 `./wp-admin/includes/theme.php` '''Line 112'''

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41665>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list