Skip to content

Instantly share code, notes, and snippets.

@jonwatson87
Last active July 8, 2016 13:16
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 jonwatson87/f1fb78449d34963bc55315cf363c60af to your computer and use it in GitHub Desktop.
Save jonwatson87/f1fb78449d34963bc55315cf363c60af to your computer and use it in GitHub Desktop.
Relabel author names from Login to Display Name when displaying Co-Authors Pro as a taxonomy in Search & Filter Pro
// Replace Co-Author labels in Search & Filter Pro (default name = login/default value=slug) with display_name
function filter_function_name($input_object, $sfid) {
if ($input_object['name'] == '_sft_author') {
global $coauthors_plus;
//udpate this field before rendering
foreach($input_object['options'] as $key => $option) {
if($option->value=="")
{//the option with no value is always the "all items" or unselected state
$option->label = "All Authors";
}
else {
$user = $coauthors_plus->get_coauthor_by( 'user_nicename', $option->value );
$input_object['options'][$key]->label = $user->display_name . ' ' . ' (' . $option->count . ')';
}
}
}
return $input_object;
}
add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment