Support

Account

Home Forums Front-end Issues Filtering / Querying Posts based on year (field stored yyyymmdd) Reply To: Filtering / Querying Posts based on year (field stored yyyymmdd)

  • This is the only way I can think to do it

    
      $archive_args = array (
        'post_type' => 'setlist-shows',
        'posts_per_page' => $posts_per_page,
        'meta_key'  => 'show_date',
        'orderby' => 'meta_value_num',
        'order'   => 'DESC',
        'meta_query => array(
          array(
            'key' => show_date,
            'value' => '20170000',
            'compare' => '>'
          ),
          array(
            'key' => show_date,
            'value' => '20180000',
            'compare' => '<'
          )
        )
      );