Title: Custom Sort Order
Last modified: February 6, 2018

---

# Custom Sort Order

 *  Resolved [wcmaster](https://wordpress.org/support/users/wcmaster/)
 * (@wcmaster)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/custom-sort-order-2/)
 * I have a site about a 5-day event that occurs on a yearly basis. Your plugin 
   would be idea to display each day’s events on a timeline. Currently, I am testing
   your plugin with added custom fields for date and time ([https://www.wp-timelineexpress.com/documentation/enable-announcement-dates-times/](https://www.wp-timelineexpress.com/documentation/enable-announcement-dates-times/)).
   But, an issue has come up that I have yet figured out.
 * The website has quite a few events that have the same start date and time. Problem
   is I would like to order these events in a specific way. Is there a way to do
   this? Like sorting by publishing date. Or add another custom field, called “sort-
   order”.
 * Also, is there a way to tell the plugin to sort the announcements by multiple
   fields — announcement-date, announcement-time, announcement-end-time, published-
   date?
 * Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Code Parrots](https://wordpress.org/support/users/codeparrots/)
 * (@codeparrots)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/custom-sort-order-2/#post-9947787)
 * Hi [@wcmaster](https://wordpress.org/support/users/wcmaster/),
 * Let me take a look and see what we can come up with as a solution for times when
   events have the same date/time.
 * I will post back here after we’ve done some testing.
 *  Thread Starter [wcmaster](https://wordpress.org/support/users/wcmaster/)
 * (@wcmaster)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/custom-sort-order-2/#post-9948946)
 * Many thanks. Look forward to what you and your team come up with.
 * FYI, I added the following custom fields to the plugin:
 * 1) announcement-location
    2) announcement-time 3) announcement-end-time
 * Cheers!
 *  Plugin Contributor [Code Parrots](https://wordpress.org/support/users/codeparrots/)
 * (@codeparrots)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/custom-sort-order-2/#post-9952416)
 * Hi [@wcmaster](https://wordpress.org/support/users/wcmaster/),
 * Can you try using the following filter to see if you this works for you:
 *     ```
       function timeline_express_fallback_to_published_dates( $args, $post, $atts ) {
   
       	$args['orderby'] = [
       		'meta_value_num' => $args['order'],
       		'date'           => $args['order']
       	];
   
       	return $args;
   
       }
       add_filter( 'timeline_express_announcement_query_args', 'timeline_express_fallback_to_published_dates', 10, 3 );
       ```
   
 * That _should_ order the announcements based on the announcement date, and if 
   the dates are the same, fallback to the post published date (set above the ‘Publish’
   button on the post edit page).
 * You can add that to your themes functions.php file, or create an MU plugin or
   custom plugin to add it to.
 *  Thread Starter [wcmaster](https://wordpress.org/support/users/wcmaster/)
 * (@wcmaster)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/custom-sort-order-2/#post-9953727)
 * Awesome! That worked out great. I look forward buying the pro version and creating
   multiple timelines for each day. Thanks for the great plugin.
 *  Plugin Contributor [Code Parrots](https://wordpress.org/support/users/codeparrots/)
 * (@codeparrots)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/custom-sort-order-2/#post-9955269)
 * Great! We are working on getting the date-time addon built out as an addon so
   all of this doesn’t require coding. The existing code snippet will also be updated
   to reflect the fallback to the published dated. The code snippet hosted in the
   docs will also continue to work, and the addon will be for those who don’t know
   and or want to write any code.
 * Thanks again! Have a great rest of your week.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Custom Sort Order’ is closed to new replies.

 * ![](https://ps.w.org/timeline-express/assets/icon-256x256.png?rev=1007462)
 * [Timeline Express](https://wordpress.org/plugins/timeline-express/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/timeline-express/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/timeline-express/)
 * [Active Topics](https://wordpress.org/support/plugin/timeline-express/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/timeline-express/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/timeline-express/reviews/)

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [published date](https://wordpress.org/support/topic-tag/published-date/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)
 * [time](https://wordpress.org/support/topic-tag/time/)

 * 5 replies
 * 2 participants
 * Last reply from: [Code Parrots](https://wordpress.org/support/users/codeparrots/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/custom-sort-order-2/#post-9955269)
 * Status: resolved