Assuming your date is in the correct format for proper ordering (yyyy-mm-dd), add a meta_query
to your args:
$args = array(
'post_type' => array('basic_events'),
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'date_of_event',
'paged' => $paged,
'meta_query' => array(
array(
'key' => 'date_of_event',
'value' => date( 'Y-m-d', current_time( 'timestamp' ) ),
'compare' => '>',
'type' => 'DATE'
)
)
);
EDIT– Changed date( 'Y-m-d' )
to date( 'Y-m-d', current_time( 'timestamp' ) )
to get the date relative to your site’s timezone settings. See current_time
in Codex for info.
Related Posts:
- WP_Query orderby date not working
- Get Recent Posts by Date in Multisite
- WordPress Custom Query to show posts from last x years
- How can I hide posts that are over 2 years old
- Date query not inclusive despite parameter being true
- Use meta_query to display events by date in custom field
- Ordering by meta_value AND date NOT WORKING with wp_query
- How to show recent and upcoming birthdays using meta_query
- Meta Query for specific months
- WP_Query meta_query >= date
- Complex date range with WP_Query and BETWEEN
- Comparing dates in custom field
- How to display upcoming events by dat with Modern Events Calendar Lite
- Orderby ASC changes to DESC in WP_Query
- Complex WP_Query order request: DESC by day, but then ASC by time
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Taxonomy and Date in same query?
- Shortcode for latest -not expired- posts
- date_query seems to be ignored by wp_query
- WP Group posts by year(desc) > month(desc) > date(asc)
- Display Current Post’s Position in Custom Taxonomy
- WordPress Custom Search Form Displaying Unexpected Results
- Filtering posts by archive showing all years
- 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
- Show single posts date, in a page of posts
- Added Date Filter To Popular Posts Query
- Comparing Meta Field date in WPQuery using Meta_Query?
- How to get only present and past posts with post_date
- WP Query for all events prior to current date
- Problem with my loops
- Sort posts on custom field AND after that sort on date?
- Get posts by birthday
- Year based WP Query
- Get post closest to today
- Query custom post type by date field only working when two posts match the query
- Get posts from similar time as current post
- Divide WP_Query posts by date & post type
- Query Posts by date range with fixed beginning and end
- Issue with sorting by post date and custom post type
- Get posts that were most recently tagged
- WP_Query sort by ACF date field (newest first) with blank dates first
- How to get an array of post data from wp_query result?
- How to only display posts whose meta_value field is not empty?
- How to print the excuted sql right after its execution
- How to add taxonomy filter on the query fly?
- post_type is ignored by WP_Query when ‘tag’ argument is included
- How to query posts of standard post format. For real
- Orderby menu_order doesn’t work
- WP_Query by Category Name
- WP_Query OR clause for tax_query and keywords
- Transient pagination not working properly
- query posts in functions.php and update a field
- get_posts() seemingly ignoring post_type
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Which filter/action hook gets triggered after a query has been performed?
- Why query_vars get altered in WP_Query Object?
- pre_get_posts filter meta_query without conflicting existing meta_query
- Get data of all posts of a query before pagination
- How to avoid wp_query returning the same post I’m on in results?
- WordPress Loop and $post
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- WP_Query tax query part of slug
- How to implement a new row_count method in WordPress?
- Some doubts about how the main query and the custom query works in this custom theme?
- How to do a wp_query with two acf-fields, sorting on one of them
- WP_Query – Object manipulation vs WordPress functions
- Only display post if published in last 24 hours?
- Transients with dynamic WP_Query
- How to remove the most recent post from $the_query
- WP_Query loop else statement not executing
- Selecting posts with a given meta value for a meta key
- pre_get_posts – editing query, tax_query
- Check if a post has term inside loop
- Display all posts in a custom post type, grouped by a custom taxonomy. How to sort the posts alphabetically and the terms by ID?
- How do I add a relation parameter to my filter query?
- Hacking ‘posts_per_page’ in WP_Query
- Post archive for certain post format
- Issue with data array format
- Add AJAX “Load more” on custom query block
- Filter sub-category from checkbox form
- Meta Box WP_Query array for showing items with a certain relationship
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Function the_posts_pagination() not compatible with WP_Query arguments
- Pagination of custom page with custom fields query
- WP_Query() not filtering posts for category
- WP_User_Query Orderby Not Working
- WordPress post_status and meta_query
- Custom query return
- WP_Query: Meta_Query with serialized value (or a workaround)
- Query All Attachments and Order by Parent Publish Date
- Filter custom post type by custom taxomony
- Query post Pagination Problem
- Pull Instagram images into an existing loop?
- Pagination showing same posts despite changing page
- Query custom post types by meta field in a term from custom taxonomy
- Filtering product search results using tags
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen
- Display only posts with thumbnails