Skip to content

Instantly share code, notes, and snippets.

@apatton-cnet
Last active December 20, 2015 03:39
Show Gist options
  • Save apatton-cnet/6065389 to your computer and use it in GitHub Desktop.
Save apatton-cnet/6065389 to your computer and use it in GitHub Desktop.
<?php
function ebs_seo_cp_sort_columns( $vars ) {
if ( isset( $vars['post_type'] ) && 'location' == $vars['post_type'] ) {
if ( isset( $vars['orderby'] ) ) {
switch ($vars['orderby'] ) {
case 'street' :
$vars = array_merge(
$vars,
array(
'meta_key' => 'street',
'orderby' => 'meta_value'
)
);
break;
case 'city' :
$vars = array_merge(
$vars,
array(
'meta_key' => 'city',
'orderby' => 'meta_value'
)
);
break;
case 'state' :
$vars = array_merge(
$vars,
array(
'meta_key' => 'state',
'orderby' => 'meta_value'
)
);
break;
case 'zip' :
$vars = array_merge(
$vars,
array(
'meta_key' => 'zip',
'orderby' => 'meta_value_num'
)
);
break;
}
}
}
return $vars;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment