Home Forums General Issues Date Picker: Query Born Today (over regular posts)


Date Picker: Query Born Today (over regular posts)

  • I been going around for three days, and I just can´t figure this out. I need to display a list of posts based on the day/month, that equals to present day/month, set up with date picker. I have the following code that works perfectly for posts based on their published date, day/month, altough not custom fields, and would be great to adapt it somehow to Date Picker:

    $posts_from_today = new WP_Query( array(
        'date_query' => array(
                'month' => date( 'n', current_time( 'timestamp' ) ),
                'day' => date( 'j', current_time( 'timestamp' ) )
        'posts_per_page' => -1,
    ) );
    if( $posts_from_today->have_posts() ){
        while( $posts_from_today->have_posts() ){
  • For the ACF field, to do something similar you would need

    $date_pattern = '__'.date('md');
    $query_args = array(
      'meta_query' => array(
          'key' => 'field_name',
          'value' => $date_pattern,
          'compare' => 'LIKE'
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.