Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Created January 11, 2013 16:01
Show Gist options
  • Save WebEndevSnippets/4511774 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/4511774 to your computer and use it in GitHub Desktop.
WordPress: Set Sorting for Admin Column on a CPT
add_filter( 'request', 'we_complete_column_orderby' );
/**
* Sorting for the 'Complete' column in Submissions (we_submission) CPT, browse admin page
*
*/
function we_complete_column_orderby( $vars ) {
if ( isset( $vars['orderby'] ) && 'we_item-complete' == $vars['orderby'] ) {
$vars = array_merge( $vars, array(
'meta_key' => 'we_item-complete',
'orderby' => 'meta_value'
) );
}
return $vars;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment