Make WordPress Core

Opened 5 weeks ago

#61551 new enhancement

Page template list lacks sorting

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

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 5 weeks ago.
sorted template list.png (308.3 KB) - added by ignatiusjeroe 5 weeks ago.
Problem solved with proposed snippet.

Download all attachments as: .zip

Change History (2)

@ignatiusjeroe
5 weeks ago

Problem solved with proposed snippet.

Note: See TracTickets for help on using tickets.