A while ago I told you how to automatically change author URL to Twitter when using Tweet Import. In this post I will give you a way to change the author displayed name as well.

It is, as usual, as simple as copying the following code and adding it to your theme “functions.php” file.

// *** Requires Tweet Import Version 1.2.2 or newer ***
if (!has_filter ('the_author', 'tweetimport_change_author_name_to_twitter')) {add_filter('the_author', 'tweetimport_change_author_name_to_twitter');}
if (!function_exists('tweetimport_change_author_name_to_twitter')):
function tweetimport_change_author_name_to_twitter($link)
{
  global $post;
  global $in_comment_loop;
  if (in_the_loop() && !$in_comment_loop):
    $twitter_author_name = get_post_meta($post->ID,'tweetimport_twitter_author' , true);
    if (!isset($twitter_author_name) || $twitter_author_name == '')
      return $link;
    return '@' . $twitter_author_name;
  else :
    return $link;
  endif;
}
endif; //tweetimport_change_author_name_to_twitter

This code just applies a custom ‘the_author’ filter that substitutes the WordPress Author Name with Twitter user @name. It uses the value in the ‘tweetimport_twitter_author’ Custom Field created by Tweet Import and whose content is the author name of the original Twitter User @name.