The current code calls get_the_author
, so it’s showing you your users’ configured display names, not their usernames specifically. One fix is to change all the display names to First Last.
Alternatively, you’ll need to write a new column handler. By default it checks for methods on the list table class called _column_<name>
or column_<name>
to call, and if it doesn’t find one it tries an action:
/**
* Fires for each custom column of a specific post type in the Posts list table.
*
* The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
*
* @since 3.1.0
*
* @param string $column_name The name of the column to display.
* @param int $post_id The current post ID.
*/
do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
so you need define a handler e.g.
function manage_stores_custom_column_handler( $column_name, $post_id ) {
if ( $column_name == 'author_fullname' ) {
$post = get_post( $post_id );
if ( $post && $post->post_author ) {
$author = get_userdata( $post->post_author );
if ($author->first_name && $author->last_name ) {
echo $author->first_name . ' ' . $author->last_name;
} else {
// Fall back to display name
echo $author->display_name;
}
return;
}
}
add_action( 'manage_stories_posts_custom_column',
'manage_stores_custom_column_handler', 10, 2 );
Note that this column won’t be linked as the original column is: unfortunately the code that does that is in a protected method in WP_Posts_List_Table so you can’t just call it but you could copy it out into your own code if you needed it.