Last active
March 3, 2021 03:24
-
-
Save contemplate/8f39dacf52f94327d46a4847a0fbd5fa to your computer and use it in GitHub Desktop.
WP Ultimate Post Grid filter to add secondary orderby date when custom meta key is selected as primary order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ORDER GRID BY DATE SECOND IF META KEY ORDER IS ENABLED | |
//add_filter( 'wpupg_get_posts_args', 'wpupg_order_by_date_second', 10, 2); | |
add_filter( 'wpupg_query_post_args', 'wpupg_order_by_date_second', 10, 2); | |
function wpupg_order_by_date_second( $args, $page ){ | |
if( $args['orderby'] == 'meta_value_num' ){ | |
$args['orderby'] = 'meta_value_num date'; | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated for new version of Post Grid