Thanks a lot to @Sally CJ for the answers. It works with changing format of start_at field and adding key in array like this :
function my_sort_custom_column_query( $query )
{
$orderby = $query->get( 'orderby' );
if ( 'dateevent' == $orderby ) {
$meta_query = array(
'relation' => 'OR',
'_start_at' => array(
'key' => '_start_at',
'type' => 'DATETIME',
),
);
$query->set( 'meta_query', $meta_query );
$query->set( 'orderby', '_start_at' );
}
}
add_action( 'pre_get_posts', 'my_sort_custom_column_query' );
Related Posts:
- Adding ‘menu order’ column to custom post type admin screen
- Style custom columns in admin panels (especially to adjust column cell widths)
- How do I set the default admin sort order for a custom post type to a custom column?
- Replacing the title in admin list table
- Make custom column sortable
- Custom sortable columns ordered by meta-value?
- Add “Last Edited by” column to custom post type list table
- How to add custom columns to Custom Post Type admin screen
- Column sorting with emtpy meta values
- manage posts custom column is not populating data from meta boxes
- Custom admin columns for ALL custom post types
- order of date column in custom post type
- Add custom column to custom post type overview in backend
- custom sortable column
- Custom Post Type, Two categories, Two columns with Pagination
- Replacing the title in admin list table
- Remove Post Page “View Post” Link
- How can I add columns to custom post tables
- Custom Post Types: Custom columns with Title submenu?
- How to show custom (checkbox) field value in admin post list?
- Adding menu_order to CPT admin page
- Custom post admin filtering by post meta (the date)
- Admin Column Text Positioning
- How do I sort a custom post type admin column using two meta keys?
- Add Post Url to Manage Edit Screen
- Problem adding column to WC Subscription [closed]
- how to check if custom post type column already exists?
- Adding HTML tags or css classes to admin columns
- Extending AZIndex plugin to use custom post types and custom taxonomies
- WP CPT Custom Sortable Column in Admin Dashboard Sort Order Random
- How to show first name and last name in custom post type columns
- Order a custom post type admin screen by a second custom post type title
- WordPress make Grandparent and great grandparent filterable in custom columns
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Custom columns doesn’t appear in custom post type
- How can I use this code on a custom database table?
- Problem with $post_id object’s property
- Pods CMS: How to add custom column to Adnvanced Content Type
- CPT Columns doesn’t show categories
- Getting post attchment URL to populate a CPT Admin Page Column
- Custom Columns for Custom Post Type Manager
- Make a custom column sortable by a value from a different custom post type
- Sorting custom post types in edit.php : Post disappear
- Custom sortable column with WPAlchemy
- Remove filter and view options from custom post type edit screen
- Add Content Column to Custom Post Type backend
- Hide Published text from custom post types column
- custom filtering admin columns
- Custom sorting in post columns by ACF Pro Select Field
- Columns depending on posts count
- Making my custom column sortable
- Default custom column to off
- Change column of row action (Quick Edit) links in WP_List_Table
- Make custom post type column sortable
- Split custom post list into two columns
- Get The Post Type A Taxonomy Is Attached To
- Custom Post type & Taxonomy URL structure
- Custom Post Type – Taxonomy Dropdown Menu?
- How to add multiple images to custom post type?
- How I check if the same post slug has not been used before publishing?
- User roles – enable custom posts disable posts
- WordPress Gutenberg-Block with ESNext (withState, withSelect)
- Importing posts in custom post type into new website
- Timepicker-addon doesn’t show – Datepicker works fine?
- Link users to a custom post type
- Conditional regex in add_rewrite_rule() for specific query filters & pagination
- How To Create A Custom Taxonomy 404 Page
- How to enable shortcodes in a custom post type?
- Ajax Check Post Status
- Custom post types and tag archive pages/permalink structure issue
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Problem querying Custom post type by custom fields
- Custom post type showing index.php
- How to create a gallery page with categories?
- Display taxonomy terms, child terms and posts in a template
- Getting thumbnails of a custom posts featured images in a page-templates metabox
- can these 3 queries be re-written as 1 query?
- cannot override post_types in WP_Query()
- How to customize work area / admin area in a custom post type without plugins?
- Make homepage the newest post of a custom post type
- Add “Select All” to custom taxonomy
- Only show columns in custom post type?
- Custom Post Type – Portfolio no longer works
- Custom menu breaks down
- Faking “Same Slug Root, Multiple Custom Post Types” with Redirects?
- Issues with static pages redirecting towards home.php
- How to apply multiple rewrite_rule to a single custom post type url?
- Query first and last name from custom post type
- WP Query filter search. Result show all posts instead just custom post type
- Subpage with custom post types inside another cpt
- Change the url of a custom post type to include taxonomy
- Add multiple custom meta boxes to different custom post types
- how to load custom single.php?
- How to show a custom taxonomy using a custom template
- I want to split this into two functions
- Add HTML before a specific div?
- Woocommerce product page is not showing custom css [closed]
- I want to understand plugin implementation of custom posts / taxonomies / metaboxes
- Issue displaying multiple TinyMCE editors with WPAlchemy