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?
- How do I set the default admin sort order for a custom post type to a custom column?
- Customize Edit Post screen for Custom Post Types?
- Filter by custom field in custom post type on admin page
- Replacing the title in admin list table
- Make custom column sortable
- Displaying custom field according to date
- Custom post type isn’t working
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Add a ‘guide’ image to custom post type admin page
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Sort a custom post with ACF: Date Picker & Display Featured!
- Use remove_meta_box conditionally on custom post type
- New “Custom Types” item in admin menu. Is this a plugin or a new wordpress feature?
- Custom columns doesn’t appear in custom post type
- How can I use this code on a custom database table?
- How to group navigation items in the admin panel
- Sortable column containing numeric values for Custom Post Type at WordPress Backend
- Problem with $post_id object’s property
- Pods CMS: How to add custom column to Adnvanced Content Type
- How to check if post/page or taxonomy post is published by admin
- Linking to Post Types from wp-admin
- Plugin or method of allowing user to rearrange custom post types with drag and drop?
- Can anyone clarify difference between archive-{posttype}.php, type-{posttype} and date.php?
- Insert Custom Post Types
- sortable columns for multiple custom post types not working
- Custom Post Type – Support “author” only for admins
- Getting post attchment URL to populate a CPT Admin Page Column
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- Add ‘page template’ column to dashboard for CPTs
- Custom Columns for Custom Post Type Manager
- Filter posts of custom post type by meta key in (List All Section)
- Make a custom column sortable by a value from a different custom post type
- 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
- Is there a hook between clicking on “Add new” and the edit screen of a new post?
- Require custom post type if is_admin() – template doesn’t show up?
- Function to add custom HTML into head in custom post-type list page
- Sorting custom post types in edit.php : Post disappear
- Multiple custom post types on same admin page
- using the loop in custom meta is messing up ‘add new’ post type
- WordPress admin for a custom post, hide/collapse the main “title” and “description” boxes
- Custom sortable column with WPAlchemy
- Remove filter and view options from custom post type edit screen
- Sortable column with custom data by date
- Add Content Column to Custom Post Type backend
- Hide Published text from custom post types column
- Metaboxes inside Tab
- 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?
- Custom sorting in post columns by ACF Pro Select Field
- Compare ACF Date field to today or yesterday
- How to hide private posts even if user is admin
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- 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
- Create an administation subpage containing posts in a certain category
- Columns depending on posts count
- Making my custom column sortable
- Custom post type doesn’t display on admin list
- Test date object against previous date in loop
- Customising the admin columns for a custom post type, but now most of the built in categories don’t display?
- Shared Custom post type between WP network sites
- Exclude categories For Custom post types
- Admin menu post type
- Default custom column to off
- WordPress Author Posts Review After Every Change In The Same WordPress Post
- Redirect preview single post link to a page
- Custom Post Type Causing Admin Sidebar UI Issue
- How to change the default orderby from “Date” to e.g. “Title” or my custom column in content type records list in admin?
- Collection of fields in a single post
- Make custom post type column sortable
- Split custom post list into two columns
- Prevent users from changing post status
- Display read only info on admin, custom post page
- Custom Plugin w/ Custom Post Types – Custom Posts Are Showing at all Privilege Levels – Is this possible to adjust?
- How to set the Screen Options for Users in the Admin Panel?
- Issue displaying multiple TinyMCE editors with WPAlchemy
- Admin menu link with variable
- column values not showing after merging two custom post types
- How to set up a private custom post type that is accessible in the administrative dashboard?