You can use the meta_query
parameter to display all events for the current month like this:
$start_date = date( 'ym01' );
$end_date = date( 'ymt' );
$meta_query = array(
'key' => 'event_date',
'value' => array( $start_date, $end_date ),
'compare' => 'BETWEEN',
'type' => 'NUMERIC'
);
$args = array(
'post_type' => 'hh_event',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'event_date',
'order' => 'ASC',
'meta_query' => array( $meta_query )
);
$the_query = new WP_Query( $args );
Related Posts:
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- Can’t query by meta_key
- Problem with my loops
- Complex WP_Query Using Post Date And Post Meta
- WP_Query – Order results by meta value
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Filter WP_Query for posts having a certain meta-value
- Can I query custom meta data through WP_Query
- Meta Query with AND & OR?
- WordPress Custom Query to show posts from last x years
- How do I search an array stored in a custom-field using WP_Query?
- Date, Time, and Timezones
- meta_value and meta_key filtering returning no posts [closed]
- Show image if author meta (profile fields) exists outside loop
- How to get posts published on the latest date?
- Select custom posts by meta_value and sort by a different meta value
- Adding custom field and querying from post table
- Conditional operator OR not working with custom fields
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- WP ForLoop to compare meta information of posts to determine what post to display
- ul list with only as many li’s as filled custom fields
- Query only displays one page_id
- Convert all dates stored in custom field
- Loop through incrementing custom fields
- Ordering posts by custom field and grouped by month
- How to show list of posts with custom field value (a date) that are coming soon
- do_shortcode close
- Search Results Page – Displaying Custom Meta Fields
- Meta query relation ‘OR’ not working as expected
- The best way to collision check in WP
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- WP_query multiple custom fields not working
- Collect Data from NEXT item while in loop
- Custom Query Fields – Altering Meta Value
- How to query for posts with either one or another custom field
- Multiple Custom Field Query
- How show post only from after custom date
- How do I list a custom field and custom taxonomies for each result in a loop?
- How to show content of custom fields in search results?
- Custom field outside the loop and inside an array
- Display metabox title for custom fields with values
- use custom field value as post category in loop
- How to update custom field of a posts in a particular category
- How to query posts by month based on date custom field?
- Order by custom date field
- Group Posts By Custom Meta Value: Date
- How can I modify my meta_query to work with prices that are stored in the database that contain dollar signs and commas?
- Filter or order based on custom field
- Compare ACF date field (if exists) and post date and order DESC
- What am I missing in this Code Block?
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- get_field values for each post on home page using wp_add_inline_style
- display ACF repater field in archive page
- Comparing Meta Field date in WPQuery using Meta_Query?
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- WordPress Admin – Automatically Sort Custom Posts by Custom Field Date Value in d-m-Y Fomat
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Sort posts on custom field AND after that sort on date?
- User Filter Options on Archive Page
- sorting in wp query based on custom field value
- Custom meta boxes – add php code inside?
- get wordpress post loop by meta box date
- Outputting custom field on home.php not outside of blog list
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Error in WP Query. If variable is empty it is displaying previous post value
- Counting number of images from loop
- Metabox value for post loop?
- Get meta value when the page is a blog archive
- WP_Query a custom field value bringing back 0 results
- How to get past and upcoming post by defining date in custom field?
- Custom search (wp query by custom fields)
- Thirtieth century date for a post
- Loop through multiple custom fields with increasing number
- How do I display posts with specific value in a custom field into my loop?
- WP_query returns error when used for custom widget
- Order a query by meta_value and then by post_date
- WP Query multiple select form – meta_query help
- How to Order Posts by Custom Fields?
- WordPress archives by custom field and date
- WP_Query based on multiple metadata comparisons
- Checking if field is set before comparing with meta_query in query_posts?
- I want my post to republish again after adding a custom field
- Show posts containing or not custom field
- Filtering posts by WORD in custom field
- Retrieve IDs from custom field, count and display results differently according to count
- Display agents (custom post type) alphabetically, except one who always shows last
- Pagination not displaying correct number of pages
- Display custom field outside the loop
- Custom field not showing
- Query posts by Custom Meta (checkbox) & Genesis Grid Loop
- Order by a meta field in query loop
- Dynamically update Custom Fields to display new dates
- WP_Query sort by ACF date field (newest first) with blank dates first
- get_the_ID() retrieves same ID on Gutenberg’s Query Loop
- Best Practice for storing aggregate data by date or other criteria?
- How to display only posts from the last day with posts published?