Support » Themes and Templates » sorting by custom field date

  • Resolved OrT

    (@ort)


    Hi all,

    I want to show 3 posts that appear today or in the future.
    My dates are stored as Y/m/d (so yyyy/mm/dd eventually).

    I’m getting a rather random result right now, using:

    $today = date('Y/m/d');
    $args=array(
       'post_type' => 'Kalender',
       'meta_key' => 'datum',
       'meta_compare' => '>=',
       'meta_value' => $today,
       'orderby' => 'datum',
       'order' => 'desc',
       'nopaging' => true,
       'showposts' => 3
    );
    $wp_query = new WP_Query($args);

    Any thoughts?

Viewing 1 replies (of 1 total)
  • Fixed – the date was set to yy/mm/d, it should have been yy/mm/dd for proper sorting (two digit day).

Viewing 1 replies (of 1 total)
  • The topic ‘sorting by custom field date’ is closed to new replies.