You need to be storing your dates in some sortable format such as YYYY-MM-DD, or as a unix timestamp, otherwise you can’t do this just with a query. Once it’s in the format YYYY-MM-DD this should work. try this:
function concerts_pre_get_posts( $query ) {
if ( !is_admin() )
return;
if ( isset( $query->query_vars[ 'post_type' ] ) && $query->query_vars[ 'post_type' ] == 'concerts' ) {
$query->set( 'orderby', 'meta_value' );
$query->set( 'order', 'ASC' );
$query->set( 'meta_query', array(
array(
'key' => 'date_value',
'value' => date( "Y-m-d" ),
'compare' => '<=',
'type' => 'DATE'
)
) );
}
}
add_filter( 'pre_get_posts', 'concerts_pre_get_posts' );
Related Posts:
- Add “Last Edited by” column to custom post type list table
- How to add custom columns to Custom Post Type admin screen
- Custom admin columns for ALL custom post types
- Add custom column to custom post type overview in backend
- How to show custom (checkbox) field value in admin post list?
- Admin Column Text Positioning
- Adding HTML tags or css classes to admin columns
- CPT Columns doesn’t show categories
- Change column of row action (Quick Edit) links in WP_List_Table
- Adding ‘menu order’ column to custom post type admin screen
- Load a script just to custom post type in admin
- Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?
- Style custom columns in admin panels (especially to adjust column cell widths)
- Loading External Scripts in Admin but ONLY for a Specific Post Type?
- Make custom column sortable
- Custom Post Type Archives by Date and Taxonomy
- Filter custom post types in admin not working
- Custom Post Type Archives by Date with Custom Permalink
- Create a dropdown with Custom Post Types as option in admin
- Ordering posts having multiple post-meta date fields
- Column sorting with emtpy meta values
- Prevent reload confirmation after AJAX save
- jQuery UI in Admin (Best Practice?)
- Admin Post Update Redirection to Posts Screen
- Exclude add_filter from the admin
- Custom Post type sort order not working in the admin area
- Unable to filter on field on edit.php page
- How to Change the Title of a Meta Box on a Specified Custom Post Type? [duplicate]
- Custom Post Type, Two categories, Two columns with Pagination
- No results searching custom post type in admin panel
- Replacing the title in admin list table
- Remove Post Page “View Post” Link
- How can I add columns to custom post tables
- Custom Post Type and taxonomies’s labels localization not working
- Custom Post Types: Custom columns with Title submenu?
- How can I add a column in the wp_list_table of the admin area?
- Show admin help message across custom post type parent and child posts
- Adding menu_order to CPT admin page
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Using WPAlchemy metabox values in another metabox
- How do I sort a custom post type admin column using two meta keys?
- Add text to wordpress admin ‘Add Post’ edit
- Add Post Url to Manage Edit Screen
- Sort admin area by custom Event Date field
- How can I change the title of an Add New page in Admin for custom post type
- Set a default category – if the user didn’t select one- before creating a post
- How to only show posts assigned to current user, only in certain post types
- Add acf field in title (admin table)
- Create a page that will be used to create a custom post type
- Custom Post Type Nav to Subpage
- Selecting a post in Dashboard
- A simple script to allow sorting of custom posts in admin?
- Trash / Draft a WordPress custom post after custom date field expires
- WP CPT Custom Sortable Column in Admin Dashboard Sort Order Random
- How to show first name and last name in custom post type columns
- Options page – dropdown of users
- No Permission to add new Page, Post or CPT with Admin role
- Filtering posts list table
- CPT Validation to not show “Post updated.”
- WordPress make Grandparent and great grandparent filterable in custom columns
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Use remove_meta_box conditionally on custom post type
- How to group navigation items in the admin panel
- Pods CMS: How to add custom column to Adnvanced Content Type
- How to check if post/page or taxonomy post is published by admin
- Can anyone clarify difference between archive-{posttype}.php, type-{posttype} and date.php?
- Insert Custom Post Types
- Custom Post Type – Support “author” only for admins
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- Custom Columns for Custom Post Type Manager
- get_post_types not working properly in admin
- Incorrect ordering of custom post type based on time
- Redirect to URL if x number of days passed
- Function to add custom HTML into head in custom post-type list page
- Multiple custom post types on same admin page
- Remove filter and view options from custom post type edit screen
- Add Content Column to Custom Post Type backend
- Hide Published text from custom post types column
- custom filtering admin columns
- How can I put content before my custom post type default pages?
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- How to set post date in post_type so that it’s same as latest post in category
- Is there any filter to add a custom attribute to the tag in admin panel?
- Compare ACF Date field to today or yesterday
- How to hide private posts even if user is admin
- Adding orderby url parameter to main CPT admin menu link
- Help Adding filter to Add Media button for custom post type
- Delete all custom posts then upload a new CSV of events
- Pagination in wp-admin for CPT
- Making my custom column sortable
- Custom post type doesn’t display on admin list
- Shared Custom post type between WP network sites
- Admin menu post type
- WordPress Author Posts Review After Every Change In The Same WordPress Post
- Redirect preview single post link to a page
- Split custom post list into two columns
- Prevent users from changing post status
- How to set the Screen Options for Users in the Admin Panel?
- Issue displaying multiple TinyMCE editors with WPAlchemy