It’s because you are checking 'event_date' == $vars['event_date']
not 'event_date' == $vars['orderby]
.
But don’t use the request
filter. Instead:
add_action( 'pre_get_posts', 'event_column_orderby' );
function event_column_orderby( $query ) {
if( ! is_admin() )
return;
$orderby = $query->get( 'orderby');
if( 'event_date' == $orderby ) {
$query->set('meta_key','_wr_event_date');
$query->set('orderby','meta_value_num');
}
}
… and don’t manually set the order
as you won’t then see the difference when toggling between ASC/DESC.
Related Posts:
- How do I set the default admin sort order for a custom post type to a custom column?
- Make custom column sortable
- Column sorting with emtpy meta values
- How do I sort a custom post type admin column using two meta keys?
- WooCommerce sort products by the actual product width(not the shipping width)
- Sort and filter custom post type posts by custom taxonomy
- Order a custom post type admin screen by a second custom post type title
- Make a custom column sortable by a value from a different custom post type
- Sorting custom post types in edit.php : Post disappear
- Remove filter and view options from custom post type edit screen
- custom filtering admin columns
- How to use multiple orderby conditions on query search results? (orderby one post type, relevance)
- Grouping and paging CPT events by month with custom field date
- Make custom post type column sortable
- Row actions for custom post types?
- remove custom post type permalink
- Sort search results by post type
- How to order posts of a custom post type by date DESC in dashboard Admin?
- Drag n Drop Post Order for multiple Custom Post Types
- How to change “Draft” string for status of custom post type to “Unavailable”?
- Sorting a query by custom field date
- Ordering Posts List By Taxonomy Terms?
- Most efficient way to search for values from CPT in Post content
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- how to sort post in admin column by recently
- order of date column in custom post type
- Title_save_pre – Simple problem that u know for sure
- Image size filtering in Media uploader according to custom post type
- custom sortable column
- How to Sort Custom Field Admin Column by Date
- Hooking into wp_export filter for custom post type [closed]
- Custom Post Row Actions
- Sort Posts Best Practice
- Custom Post Type sorted by Title
- Adding menu_order to CPT admin page
- Custom post admin filtering by post meta (the date)
- Admin Column Text Positioning
- Filter home_url for custom post type
- Add Content Exclusively to a Custom Post Type Feed
- Add Post Url to Manage Edit Screen
- How to make in WordPress admin panel sortable column for the custom field, that count the number of page impressions?
- How to rank custom post type from score points
- Adding HTML tags or css classes to admin columns
- Default sort on admin columns with meta date hides draft posts with empty date value
- Filtering WP_Query
- Categories sorting
- Wp_query: sort by PHP variable
- Crafting WP_Query array, sort by date
- Displaying custom taxonomy in the admin list of a custom post type
- How can I run this code once so that my generated post title doesn’t keep changing on publish/update?
- WP CPT Custom Sortable Column in Admin Dashboard Sort Order Random
- How to show first name and last name in custom post type columns
- Filter term taxonomy metabox in custom post type
- How to change the post type a theme shows by default?
- filter custom post in rest api with custom function
- manage_edit-{post_type}_sortable_columns sorts, but wrong!
- Loop filtering Custom Post Types and/or Categories
- WordPress make Grandparent and great grandparent filterable in custom columns
- How to use manage_$post_type_posts_columns with underscore in post type?
- Search filter triggered & sort by custom post type
- How to order posts of a custom post type by date DESC in dashboard Admin?
- Is there any way to get list of all possible filter hooks for all post types?
- Can I display custom post types in home.php or need page template?
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- wp_insert_post wrong post type [closed]
- Pods CMS: How to add custom column to Adnvanced Content Type
- How can I remove filters from custom post types?
- Creating a “glossary” of WordPress posts of a specific post type
- how to retain the ability to modify the post slug after applying a post_type_link filter?
- Custom Columns for Custom Post Type Manager
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- How to filter url on post submission?
- sort by name (slug) custom post type
- Modify a plugin function output from another plugin
- Custom Taxonomy Filter Issues
- Custom loop request based on custom field
- Filter search posts by post meta?
- Modifying search results based on post_type
- conditional filter
- Is there any filter to add a custom attribute to the tag in admin panel?
- Store a value in global scope after init hook is fired
- Filter posts by their related field’s custom field
- Custom post type order by post_title
- add_rewrite_tag broke permalinks that doesn’t use that specific tag
- Insert custom taxonomy into category query
- Group Custom Posts Types in a Relation field of ACF
- Help Adding filter to Add Media button for custom post type
- sorting in wp query based on custom field value
- how it’s possible to show from a post of a custom post type the taxonomy/terms?
- Enable shortcodes on custom post type
- Creating adminable dynamic filtering on custom post type
- Menu disappears with custom post type link
- add current-menu-item to multiple custom post types
- using ACF datepicker to filter posts on a page
- Restrict a filter to a custom post type. Am I doing this right?
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- Sort CPT by taxonomy AND THEN by custom field
- Custom order of CPT posts by title, in wp-admin area by default
- Sorting by Title for Post Archive Categories for Custom Post Type
- Add post id to url instead of WordPress default -2 suffix