Last active
July 8, 2016 13:16
-
-
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
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
// 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