Support

Account

Home Forums ACF PRO WP Query orderby date field

Solved

WP Query orderby date field

  • I know there’s loads of posts on this but nothing I I’ve tried from the suggestions will affect the ordering of posts in this query. I need to order by the custom field exhibition_item_end_date Can anyone spot something that might be wrong? Thanks

     $today = date('Ymd');
      $args = array(
        'post_type' => array( 'exhibitions' ),
        'posts_per_page' => '-1',
        'orderby'	     => 'meta_value',
        'order'	     => 'DESC',
        'meta_query' => array(
          array(
            'key'		=> 'exhibition_item_end_date',
            'compare'	=> '<',
            'value'		=> $today,
            )
          ),    
      );
  • OK so this was actually due to a conflict with the Posts Types Order plugin, the query works as expected.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.