[wp-trac] [WordPress Trac] #61551: Page template list lacks sorting
WordPress Trac
noreply at wordpress.org
Tue Jul 2 19:49:16 UTC 2024
#61551: Page template list lacks sorting
--------------------------------+-----------------------------
Reporter: ignatiusjeroe | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 6.5.5
Severity: normal | Keywords:
Focuses: ui, administration |
--------------------------------+-----------------------------
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
<?php
// Sort template names using "natural ordering"
foreach ($post_templates as &$value ){
natsort($value);
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61551>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list