Skip to content

Instantly share code, notes, and snippets.

@contemplate
Last active March 3, 2021 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save contemplate/8f39dacf52f94327d46a4847a0fbd5fa to your computer and use it in GitHub Desktop.
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
// 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;
}
@contemplate
Copy link
Author

Updated for new version of Post Grid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment