Title: Please add this code block for sorting CPTs
Last modified: May 15, 2026

---

# Please add this code block for sorting CPTs

 *  [dfaltermier](https://wordpress.org/support/users/dfaltermier/)
 * (@dfaltermier)
 * [3 months, 2 weeks ago](https://wordpress.org/support/topic/please-add-this-code-block-for-sorting-cpts/)
 * Hello,
 * I have a feature request, one that was requested some years ago but never implemented.
 * Please consider adding the code block below to the ‘Show modified Date in admin
   lists’ plugin. This will allow custom post types to be **sorted** by modification
   date. This is a need my company has, as with anyone needing this feature for 
   pages and posts. There’s no downside that I know of in providing this feature.
   I have tested this locally.
 * Thanks for your consideration.
 *     ```wp-block-code
       /** * Registers the 'Modified Date' column as sortable for all public custom post types. * * Runs on init at priority 20 to ensure all custom post types have been registered * (typically at priority 10) before iterating them. The built-in post/page/media * cases are handled by the static filters above; this covers any non-built-in CPT. * Each CPT gets its own dynamic filter: manage_edit-{post_type}_sortable_columns. */function modified_column_register_sortable_for_cpts() {	$custom_post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'names' );	foreach ( $custom_post_types as $post_type ) {		add_filter( "manage_edit-{$post_type}_sortable_columns", 'modified_column_register_sortable' );	}}// Run after CPTs are registered (priority 20) so get_post_types() returns them all.add_action( 'init', 'modified_column_register_sortable_for_cpts', 20 );
       ```
   

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fplease-add-this-code-block-for-sorting-cpts%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/show-modified-date-in-admin-lists/assets/icon-128x128.png?
   rev=1530834)
 * [Show modified Date in admin lists](https://wordpress.org/plugins/show-modified-date-in-admin-lists/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/show-modified-date-in-admin-lists/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/show-modified-date-in-admin-lists/)
 * [Active Topics](https://wordpress.org/support/plugin/show-modified-date-in-admin-lists/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/show-modified-date-in-admin-lists/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/show-modified-date-in-admin-lists/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [dfaltermier](https://wordpress.org/support/users/dfaltermier/)
 * Last activity: [3 months, 2 weeks ago](https://wordpress.org/support/topic/please-add-this-code-block-for-sorting-cpts/)
 * Status: not resolved