[wp-trac] [WordPress Trac] #49194: Page Template dropdown ordering should be by title, not value

WordPress Trac noreply at wordpress.org
Thu Sep 11 13:40:06 UTC 2025


#49194: Page Template dropdown ordering should be by title, not value
-------------------------------------------------+-------------------------
 Reporter:  leec87                               |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Posts, Post Types                    |     Version:
 Severity:  minor                                |  Resolution:
 Keywords:  good-first-bug needs-patch has-      |     Focuses:  ui,
  test-info                                      |  administration
-------------------------------------------------+-------------------------
Changes (by SirLouen):

 * keywords:   => good-first-bug needs-patch has-test-info
 * type:  enhancement => defect (bug)
 * milestone:  Awaiting Review => Future Release


Comment:

 == Reproduction Report
 === Description
 ✅ This report validates that the issue can be reproduced.

 === Environment
 - WordPress: 6.9-alpha-60093-src
 - PHP: 8.2.29
 - Server: nginx/1.29.1
 - Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
 - Browser: Chrome 140.0.0.0
 - OS: Windows 10/11
 - Theme: Minimal Theme 1.0.0
 - MU Plugins: None activated
 - Plugins:
   * Test Reports 1.2.0

 === Testing Instructions
 1. I'm using a very minimal theme [https://developer.wordpress.org/themes
 /classic-themes/your-first-theme/#classic-theme like this]
 2. Then as commented in the OP, created the 3 templates, like
 `a-template.php`, `b-template.php`, `c-template.php`
 3. Finally add the code in the supp artifacts to add a menu item to
 display with `get_page_templates`
 4. 🐞 Exactly as commented, ordering is done by file name and not by
 template name as it should

 === Actual Results
 1.  ✅ Error condition occurs (reproduced).

 === Supplemental Artifacts

 Added this to functions.php:

 {{{
 function page_templates_admin_menu() {
     add_menu_page(
         'Page Templates',
         'Page Templates',
         'manage_options',
         'page-templates',
         'page_templates_admin_page',
         'dashicons-media-code',
         81
     );
 }
 add_action( 'admin_menu', 'page_templates_admin_menu' );
 function show_page_templates() {

 }


 function page_templates_admin_page() {
     $templates = get_page_templates();
     echo '<div>';
     echo '<h1>Page Templates</h1>';

     echo '<ul>';
     foreach ( $templates as $filename => $name ) {
         echo '<li>' . $name . ' (' . $filename . ')</li>';
     }
     echo '</ul>';
     echo '</div>';
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49194#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list