Age of Article Warning:
This article was originally published 44 months ago. The tips and techniques explained may be outdated, or information may longer be applicable. Please consider this when viewing the below content.

add google authorship to wordpress

***important update:
this article is old – please read the updated version at:

How to setup Google Authorship, Google Publisher and link to your website

 

This post will show you how you can easily add Google Authorship to your WordPress website.

Why should you do this? Well Google is probably the biggest search engine in the world, by far, so why wouldn’t you want to tell Google which articles you have written. Plus you get to see a nice picture of yourself in the Google SERP.

But seriously, Google has started to integrate social indicators in its search engine results, so adding authorship markup to your blog or website is a “must do”.

Depending on your theme, this may be somewhat different, however the basic principles are the same. You need to setup your WordPress author page so that it contains the link to your Google+ profile, and then because your posts actually link to your author page, Google sees that you are the author and grants you “Google Authorship” for your posts.

There are 3 main steps to successfully adding Google Authorship to your WordPress site. The first step is to create a Google+ personal profile, if you haven’t already done so, and add a link in the “contributor to” section to the website(s) you author articles on.

googleplus contributor to

Secondly you need to take note of your profile ID – see image snapshot below. At this point, you could use one of many plugins to add Google+ to your page, though I think it’s an easy addition to do it yourself.

google plus profile id

You need to add your Google+ profile URL, onto the author page. To do this we will modify 3 areas, namely your author profile page found inside your WordPress admin section via “User > Your Profile” page, your childtheme’s functions.php file and also the author.php template file.

Inside WordPress admin, on your profile page, under Contact Info, there is email, website, AIM, Jabber and others. Ideally there should really be Google+, Facebook and Twitter fields, so we’ll clean this up a little. We can add these extra fields onto the page with a function. Add the code below to your childtheme’s functions.php file. It will remove the AIM, Jabber and Yahoo IM fields, and replace with Google+, Twitter and Facebook.

[php]
function modify_user_contact_methods( $user_contact ){

/* Add user contact methods */
$user_contact[‘googleplusprofile’] = __(‘Google+ Profile ID only’);
$user_contact[‘twitter’] = __(‘Twitter Username only’);
$user_contact[‘facebookpage’] = __(‘Facebook Page ID only’);

/* Remove user contact methods */
unset($user_contact[‘aim’]);
unset($user_contact[‘jabber’]);
unset($user_contact[‘yim’]);

return $user_contact;
}

add_filter(‘user_contactmethods’, ‘modify_user_contact_methods’);

?>
[/php]

Now when you go into the user profile page, you can add your Google+ profile ID, as well as Facebook and Twitter.

Next up we need to use that new profile information on the author page. We will use $curauth to extract this data from your Profile Page, and then add it to your author page.

You need to edit the author.php file on your website, or if your theme doesn’t have one, then make a copy of the archive.php file and name it author.php.

What we want to do is to insert the following code onto your author page, automatically extracting your Google+ profile ID:

[php]<a href="https://plus.google.com/GOOGLE-PLUS-PROFILE;?>" title="Google+ Author" rel="author" target="_blank">[/php]

To do this you add the following code just before the Loop in the author.php template file:

[php]
$curauth = (isset($_GET[‘author_name’])) ? get_user_by(‘slug’, $author_name) : get_userdata(intval($author));?>
<h2>Author: <a href="https://plus.google.com/<?php echo $curauth->googleplusprofile;?>" title="Google+ Author" rel="author" target="_blank"><?php echo $curauth->nickname;?></a></h2>
<?php if ( !empty( $curauth->twitter ) ) { ?>
<br/><p>Find me on Twitter at: <a href="https://twitter.com/<?php echo $curauth->twitter; ?>" target="_blank">www.twitter.com/<?php echo $curauth->twitter;?></a></p><?php
} ?>
<?php if ( !empty( $curauth->facebookpage ) ) { ?>
<br/><p>Find me on Facebook at: <a href="http://facebook.com/<?php echo $curauth->facebookpage; ?>" target="_blank">www.facebook.com/<?php echo $curauth->facebookpage;?></a></p><?php
} ?>
<br/><h3>A little bit about me:</h3><?php echo $curauth->user_description; ?></p>

<br/><h2>Articles by <?php echo $curauth->nickname; ?>:</h2><?php
[/php]

You can of course style this snippet of information how you like, but the important part is that it adds the link to your Google+ profile page onto your WordPress author page and states that you are rel=”author”.

Now you can test that you have done everything correctly by using the Google Rich Snippets Tool here

Setting up Google Authorship on your WordPress website was last modified: August 8th, 2014 by David Tiong
Setting up Google Authorship on your WordPress website