Date and Time Picker Field
Posts not sorting by time field (2 posts)

  1. Sean M.
    Posted 2 years ago #

    Hi, I can't get posts to sort by the time field regardless of format used. I checked the values being saved to the DB, by enabling custom fields for the post type and verifying the value stored and they appear to be correct UNIX timestamps.

    What I'm experiencing is that the posts sort by numerical value (e.g. 12:00 PM comes after 6:00 PM) and despite trying even using a 'meta_query' alongside the typical 'orderby' with 'meta_key' and 'meta_value_num', I can't seem to get the posts to sort correctly. Not sure what I'm doing wrong. Here's an example of the query I'm running:

    <?php $args = array(
    	'post_type' => 'saturday_event',
    	'orderby' => 'meta_value_num',
    	'meta_key' => 'start_time',
    	'order' => 'ASC',
    	'nopaging' => true
    query_posts( $args );
    while ( have_posts() ) : the_post(); ?>

    Anybody know what might be wrong here? Thanks for your help!


  2. roflman79
    Posted 1 year ago #

    You need to check the option, save as UNIX timestamp.

    This should fix the ordering then.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Date and Time Picker Field
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic