Home › Forums › General Issues › How to filter posts by event month › Reply To: How to filter posts by event month
Dates are stored in the format YYYYMMDD. To get only posts for a specific month, lets say July of 2015. You would need to dynamically insert the year and month into the following for whatever month you need.
$args = array(
'meta_key' => 'event_date', // name of custom field
'orderby' => 'meta_value_num',
'order' => 'DSC',
'cat' => '2'
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'event_date',
'value' => '20150701',
'compare' => '>=',
),
array(
'key' => 'event_date',
'value' => '20150731',
'compare' => '<=',
),
),
);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.