Skip to main content
2 of 2
added clarification
Steve
  • 313
  • 9
  • 21

Display posts where date field matches current month?

I have a loop which displays all the posts of the "events" post type on my site. Each of these posts has a custom date field "event_date", which I sort the display of the loop by.

I would like to simplify my post management by only display posts which match the current month; that is, as of today (Dec.30) all the December posts display but on January 1, all the January posts display.

Note this is not post date, it's the value of the field (when the event takes place). I want to keep the month's worth of posts up ll month even when their date passes -- so always the complete month.

Most of the posts I found here with search are dealing with the post date, whereas I need to use the value of this custom field instead. Thanks. My current query:

$args = array( 'post_type' => 'hh_event', 'posts_per_page' => -1,'orderby' => 'meta_value', 'meta_key' => 'event_date', 'order' => 'ASC'  );
            $the_query = new WP_Query( $args );

To add to this, the field is a custom field made with the Advanced Custom Fields plugin, and the date is save by this as yymmdd.

Steve
  • 313
  • 9
  • 21