Make WordPress Core

Opened 2 years ago

#61551 new enhancement

Page template list lacks sorting

Reported by: ignatiusjeroe Owned by:
Priority: normal Milestone: Awaiting Review
Component: Editor Version: 6.5.5
Severity: normal Keywords:
Cc: Focuses: ui, administration

Description

This issue wont be apparent in the Page Block Editor (or classic editor) if your theme has no page templates or templates with similar names. I've created dummy template files that contained a number in their names. WP currently doesnt do any sorting which makes the template list look very disorganized. See attached images.

Solution:
Add the following snippet to the method 'get_post_templates' of class WP_Theme, right above "$this->cache_add( 'post_templates', $post_templates );"

Snippet:

<?php
// Sort template names using "natural ordering"
foreach ($post_templates as &$value ){
  natsort($value);
}


Attachments (2)

unsorted template list.png (310.0 KB ) - added by ignatiusjeroe 2 years ago.
sorted template list.png (308.3 KB ) - added by ignatiusjeroe 2 years ago.
Problem solved with proposed snippet.

Download all attachments as: .zip

Change History (2)

@ignatiusjeroe
2 years ago

Problem solved with proposed snippet.

Note: See TracTickets for help on using tickets.