Home Forums Front-end Issues Displaying posts using a custom date field Reply To: Displaying posts using a custom date field

  • 1- it should be just start_date. That is the meta key which is the same as the field name.

    2 – You should change the check to check for your post type that way the query is only changed for your post type.

      if (isset($query->query_vars['post_type']) &&
          $query->query_vars['post_type'] == 'your-post-type-here') {

    3- You must be using ACF4. ACF 5 has a Display Format and Return Format and always stores all dates as YYYYMMDD. You will need to alter your save format to something that is recognized as a date by WP. Either that or you’ll need to set the meta type to CHAR or NUMBER I think.

    When posting code you should put it inside back ticks, or use the code button at the top of the reply box, makes it a lot easier to read.