The function add_sortable_date_column only registers columns as sortable.
Add one more function to tell wordpress how to sort your columns.
function courses_columns_orderby( $query ) {
if( ! is_admin() )
return;
$orderby = $query->get( 'orderby');
switch( $orderby ){
case 'online_start':
$query->set('meta_key','online_start');
$query->set('orderby','meta_value');
break;
default: break;
}
}
add_action( 'pre_get_posts', 'courses_columns_orderby' );
Related Posts:
- How do I set the default admin sort order for a custom post type to a custom column?
- Using meta_query, how can i filter by a custom field and order by another one?
- How to order adjacent posts (prev / next) by custom field value?
- Sorting a query by custom field date
- Custom Taxonomy Template Post List with Sort Order
- How to sort a table of custom posts by column containing custom field
- How to Sort by Date When Using d-m-Y Format
- Sort by two dates. Default entry date and custom field if present
- Sorting custom post type columns with external data and without meta values
- WP_Query order by custom field, then randomly order some of results
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Sort custom post type by most current date picker
- Make a custom column sortable by a value from a different custom post type
- How can I sort the order of multiple custom field values in a custom post type?
- sorting in wp query based on custom field value
- Sort CPT by taxonomy AND THEN by custom field
- How to Add Custom Fields to a Custom Post Type?
- Do_Shortcode not working for Embed
- Sort custom post type list table by display name of a user id stored as post meta value
- Display custom post type and custom fields within a Bootstrap Carousel
- how to filter by last name for custom post
- Search that will look in custom field, post title and post content
- clients list using wordpress
- Display Custom Post Type Fields
- How to do a custom bookmarks post type?
- How do I add media to a custom post type?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- WordPress query by multiple Custom fields and order by date
- Add New Post (Custom Post Type) Deletes 1 Post’s Custom Meta Data
- How to use custom field to search for wordpress post type?
- WP Query group/order by category name
- Custom search with Custom Fields in WP REST API?
- Adding a Gutenberg-like custom field on a custom post type
- Automatically populate a hierarchical taxonomy from a custom field
- WordPress posts with multiple fields
- How to dynamically attach pictures to a carousel
- How to add a Custom Meta Box for more than one Post Type?
- Custom post type ‘orderby’ => ‘meta_value’ not working
- WordPress custom loop filter by meta_key and value with serialize data
- Give a permalink to Custom Post Types without title
- How do I create custom fields for multiple post types?
- Cannot add custom field to “orderby” parameter in Rest API
- Custom Meta Field – Remove comma from string with str_replace
- WooCommerce sort products by the actual product width(not the shipping width)
- Tracking changes in admin-page so user gets warning when leaving the page
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- First custom field value (out of several) displayed twice after query
- Multiple Frontend Filters Using Advanced Custom Fields
- Is it possible to activate customfield ‘text description’ upon activating the customfield ‘checkbox’?
- Add a custom meta box for client to order CPT posts how they want
- create custom meta box with default value
- Add custom attributes to a post
- Custom Post Type page sorts differently on different environments
- Custom Taxonomy Search result page
- Get post content from another section in custom single page
- Modify Posts from Custom_Post_Type within the plugin
- How to convert custom fields to content
- Increasing the default number of posts in custom post types
- Group by custom field value (start and end times)
- Variable Products as custom post types
- How to call a post’s metadata in shortcode.php?
- updating one custom meta field only
- Get post-meta value of all custom-posts – lowest to highest year-count?
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- Create list from custom field comma separated values
- What’s an easy way of sorting custom post types manually?
- Get previous and next custom post by custom field
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- Create an user checklist system for a course plateform using ACF Pro and ACF Extended
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- WP_Query get always custom post_type for first
- Post Click Redirect to Custom URL instead of Single Post Page
- wp_insert_post deleting previous post custom meta
- Show posts from WP Custom Post Type selected from a field in a metabox
- How to sort post category using its Description
- meta query multiple values for the same key
- Show Post columns to specific users on condition
- Custom post types – meta_query: search lesson which starts sooner
- Wp Query sort order from custom MetaBox
- Populate custom post type/custom fields from an external database
- Custom Field to post_title
- Automatically convert standard posts with custom fields to custom post types
- Importing URLs of Audio Enclosures
- Retrieving custom post type fields without a post
- Get month and day from a Date Picker custom field
- custom fields not showing before get_header
- pre_get_posts with multiple post types AND a meta_key
- Search form to find custom meta box generated data
- Display Custom Post if custom field is marked
- predefined custom field on registration page
- Show Custom Post Type taxonomy term that matches custom field
- Select Menu for Custom post Type does not save
- loop through custom post-type with two meta_keys
- Allow authors to create article image
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts