Created
January 11, 2013 16:01
-
-
Save WebEndevSnippets/4511774 to your computer and use it in GitHub Desktop.
WordPress: Set Sorting for Admin Column on a CPT
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
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