[wp-trac] [WordPress Trac] #56394: Add docs to clarify that `get_page_template()` doesn't work on block themes

WordPress Trac noreply at wordpress.org
Tue Aug 16 21:52:02 UTC 2022


#56394: Add docs to clarify that `get_page_template()` doesn't work on block themes
--------------------------+-------------------------
 Reporter:  audrasjb      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  6.1
Component:  Editor        |    Version:  5.9
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:  docs          |
--------------------------+-------------------------
 As of today, `get_page_template()` doesn't work on block based themes, and
 it should be documented accordingly in the docblock of this function.

 For example, the following sample snippet can be used in the functions.php
 file of any theme. It outputs the value returned by `get_page_template()`
 right after `<body>` opening tag.

 {{{
 function test_get_template_page() {
         $template = get_page_template();
         echo '<div style="position: absolute; top: 20px; width: 100%;
 padding: 1em; background: #fff; color: #000;">' . $template . '</div>';
 }
 add_action( 'wp_body_open', 'test_get_template_page' );
 }}}

 It always return `my-website/wp-includes/template-canvas.php` on a block
 theme. This backward compatibility issue should be documented accordingly.

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


More information about the wp-trac mailing list