If you want to override the default- and the title ordering, and order instead by the last word in the title.
/**
* Override default- and title ordering in the backend, for the 'speaker' custom post type.
*
* @link https://wordpress.stackexchange.com/a/202154/26350
*/
add_action( 'pre_get_posts', function( \WP_Query $q )
{
if (
is_admin()
&& $q->is_main_query()
&& 'edit-speaker' === get_current_screen()->id
&& ( '' === $q->get( 'orderby' ) || 'title' === $q->get( 'orderby' ) )
) {
$q->set( 'orderby', 'wpse_last_word' );
$q->set( 'order', '' !== $q->get( 'order' ) ? $q->get( 'order' ) : 'ASC' );
}
} );
where we use the plugin from our last answer to support the wpse_last_word
ordering.
Related Posts:
- Order posts by (hierarchical custom) taxonomy terms and term children
- Order posts by taxonomy terms
- What’s the most efficient way to get two queries based on an if statement?
- How to set up a private custom post type that is accessible in the administrative dashboard?
- WP-ADMIN – Listing all CPT in “posts” listing
- manage_edit-{post_type}_sortable_columns sorts, but wrong!
- Custom Post Type Archive Error, Takes Last Post as Title and Doesn’t Work
- Get the taxonomy of a post hierarchically
- Change sort order when using ‘orderby’ => ‘type’
- Display Woocommerce Orders for specific author [closed]
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Ordering custom post type by multiple custom fields
- Custom Postype specific changes in admin panel
- Grouping of CPTs and taxonomies into menu groups in admin
- Manage Columns : order by post_parent’s title
- Order by custom field meta_key date and then by custom file meta_key number
- It’s possible to hide body copy box for a custom post type?
- Show data from one Custom Post Type in another Custom Post Type
- Archive not sorting correctly
- Add a custom text to admin footer in a Custom Post Type page
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Ascending Order is not Working in Custom Post Type Listining
- Creat new admin url for custom post type
- Custom Field values not Showing in Edit Page of Custom Post Type
- Add a custom meta box for client to order CPT posts how they want
- Query multiple taxonomies with pre get posts
- Main menu not appearing in custom post type archive
- WordPress custom post type capabilities issue
- Custom post type sorting: alphabetical order
- Set thumbnail and title for a post type archive (not post itself!)
- Custom WP_Query doesn’t display all posts
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- $wpdb->get_col and ORDER BY?
- Hide Status Option From WordPress Publish Metabox and Rename Published on:
- Create field of Custom Post Types
- how to show records that don’t have custom meta value
- CPT is simply not displayed in the main archive with “pre_get_posts”
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- WP_Query of custom post type sorted by meta_key has unexpected results
- Custom posts of one type have disappeared from admin. Still appear on site [closed]
- How to get the custom post list to admin user edit page?
- WP_Query not resetting after wp_reset_postdata
- Copy order items with metadata between orders – Woocommerce
- How to query for posts (hierarchical custom post type) that have children but are NOT top level?
- Change link for “add new” buttons on custom post type
- CPT Archive pre_get_posts not working?
- Custom Post Type – Portfolio no longer works
- How do I edit the WordPress post.php file?
- Add data to post edit page, when post is published
- Custom capabilities not reflecting on admin panel
- Post ordering not working with custom field
- How to limit what Editors see in the admin?
- Multiple wp_editor instances in custom post type using Ajax
- Filtered by a custom field, ordered by another
- orderby parameter not working in custom query
- Questions regarding add_meta_box()
- Adding Page Ordering to a Custom Page Type
- pre_get_posts works in post type archive but not in single post
- Change Post Meta via AJAX from the posts list table
- Custom Attachment Type
- Displaying Portfolio Filter by Category Order (alphabetically)
- Sorting custom post types in edit.php : Post disappear
- How to customize `Edit-Post` Screen
- Sort by post word count in admin area
- show most viewed posts of last days by link?
- Changing WordPress sort order for returned child pages
- How to display magic field’s custom write panel in wordpress theme?
- jQuery UI & Admin (Calendar)
- Change ordering of fields of custom post type in admin page
- How to display author details in a custom post type in the wordpress backend?
- Add Content Column to Custom Post Type backend
- Change Text in Admin Panel
- Admin slow on Postlist (over 30k Posts in Database)
- How to use pre_get_posts on archive page custom post type
- Hide title field of selected post-types on edit pages
- How can I put content before my custom post type default pages?
- wp rest api orderby field in a custom table
- get_posts() returns empty on custom post type /wp-admin/edit.php
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- Put featured image under post title in admin area
- list articles in admin showing nested categories or slugs?
- Display Parent-Child Posts in specific order by comparing IDs in array
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- How to display an admin-notice after custom post type edit modification
- How can I sort the results of a REST API response by the title of a connected custom post type?
- Query to Exclude Child Pages from Custom Post Type Archive
- Admin Post Table – Remove Title Edit Link
- Sort custom post column by generated value?
- Add Custom Field in Product in WP Admin and send to Order Webhook
- How do I troubleshoot pre_get_posts with Debug Bar?
- Publishing failed. The response is not a valid JSON response
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- Limiting the Number of User Posts to Their Own Posts
- How to order taxonomy terms by most recent post?
- How to overwrite function to display parent page combobox for custom post type in Edit Post Page?
- Orderby if between two meta fields
- Display custom posts, ordered by most commented, without duplicates
- How to hide private posts even if user is admin