Link Author Name on Archives to Google Profile

This document is deprecated! The information on this page refers to a Thesis version that is now obsolete. Please visit the Thesis Docs for current documentation.

If you or your fellow WordPress authors have a Google Profile, you may want to link to it as a resource for more information. This article explains how to link the author name, which appears as the intro on your Author archives pages, to the author’s Google Profile.

First, we’ll need to create a field on the User Profile to store the Google Profile URL for each author. Add the following code to custom_functions.php:

// Add Google Profile to Contact Methods
function google_profile($user_contactmethods) {
    $user_contactmethods['google_profile'] = 'Google Profile URL';
    return $user_contactmethods;
}
add_filter('user_contactmethods', 'google_profile', 10, 1);  

Now, when you edit your User Profile, you’ll see a field for entering your Google Profile URL:

User Profile

Extra Field for Google Profile URL

One you’ve filled in that field (the URL will be https://profiles.google.com/UNIQUEIDENTIFIER, where a string of numbers is the unique identifier), then you’ll need to add the code necessary to link the author name to that URL to your custom_functions.php:

// Link Author Name on Author Archives to Google Profile
function my_archive_intro_headline($output) {
	global $wp_query;
	if (is_author()) {
	$author = $wp_query->query_vars['author'];
	$author_name = get_author_name($author);
	$profile_url = get_the_author_meta('google_profile',$author);
	$output = str_replace($author_name, '<a rel="me" href="' . $profile_url . '">' . $author_name . '</a>',  $output); 
	}
return $output;
}

add_filter('thesis_archive_intro_headline','my_archive_intro_headline');

That’s it!