Home Forums General Issues Order by date problem when same value Reply To: Order by date problem when same value

  • If this is a bug it would be a WP bug. But looking at your query there are few things that stand out. One is that you have a meta_query that I don’t think you need and the second is that in that meta_query you are telling that the meta field is a date and I’m pretty sure that WP expects this to be in YYYY-MM-DD format, so your dates may be being read wrong. The last thing is that you are using orderby => meta_value_number.

    Try this for your query:

    $args = array(
        'post_type' => 'project',
        'meta_key' => 'project_date',
        'orderby'=> 'meta_value',
        'order' => 'DESC',
        'paged' => $paged
    $wp_query = new WP_Query($args);
    get_template_part('templates/loop', 'project');