WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] sorting by custom field date (2 posts)

  1. OrT
    Member
    Posted 2 years ago #

    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?

  2. OrT
    Member
    Posted 2 years ago #

    Fixed - the date was set to yy/mm/d, it should have been yy/mm/dd for proper sorting (two digit day).

Topic Closed

This topic has been closed to new replies.

About this Topic