Add Support for Google’s rel=author Microformat

Applies to Version(s): Thesis 1

New Method

Google authorship has been made easier with new options for adding “rel=author” code that passes the Google rich snippet tools test.

Step one is now extremely simple in Thesis. You have two options.

The first option is to use the Thesis interface. Following this click sequence:

WP Admin > Thesis > Site Options > Document Head > Additional Scripts

You can simply paste this into the available area:

<link rel="author" href="https://plus.google.com/XXXXXXXXXXXXXX/posts"/>

Replace the X’s with your Google Plus number — this can be found if you visit Google+ while logged into the system… simply look at your address bar to locate your unique number.

The alternative — if you prefer you add this as a function — would be to add this to your custom_functions.php file contents:

function google_rel_author_in_document_head() {
echo '<link rel="author" href="https://plus.google.com/XXXXXXXXXXXXXX/posts"/>';
}
add_action('wp_head', 'google_rel_author_in_document_head',99);

As with the first option, replace the X’s with your unique Google Plus number.

The second and third steps are checklist items within your Google Plus account.

In your Google Plus profile, verify that you have a public link “back” to your Thesis site. The basic concept here is that Google’s authorship places small images of authors next to content the author has produced.

The impact of visual “social proof” can dramatically increase the click-through rate (CTR, the percentage of those who see your content in search results pages who then click your link) for your posts and pages.

In other words, you’ll want to add a link from your Google Plus profile to the site on which you placed the PHP code from Step 1 above, as this is a critical step to getting your smiling face in Google search results!

Finally, confirm in your Google Plus profile that your “+1s” are set to “public” — if they are set to private, be sure to change this.

With the code above and a couple of quick additions to your Google Plus profile, you now have a good chance of finding yourself shown as an author in Google search listings!

Older Method

In June 2011, Google announced its support of the “author” microformat.

WordPress has long supported author archives, which sites (especially those with multiple authors) can use to highlight an author’s work on the site, their biography, an author picture, or whatever else they wish.

Google’s recognition of the “author” tag allows them to link what you write on an “author”-enabled website to you by way of your WordPress author archive. To take this one step further, you can also link to your author archive on your Google profile.

The key to all of this is the “author” microformat, and adding it to your site is easy!

First, ensure that Thesis is set up to display author links. The relevant options are located in the admin panel under Thesis Design Options > Display Options > Bylines. Ensure that “Show author name in post byline” and “Link author name to archives” are checked; note that the latter option will not appear until you select the first.

Because the idea is to get Google to recognize your author archives to use as part of your online identity, do not check the “Add nofollow to author links” option.

Now, once that is complete and you have saved the options, open your Thesis custom_functions.php file, and add the following code:

/* Enhance bylines with the 'author' microformat */
function custom_headline_catcher() {
	ob_start();
}
function custom_headline_catcher_end() {
	global $thesis_design;
	if ($thesis_design->display['byline']['author']['nofollow'])
		$output = str_replace( 'rel="nofollow"', 'rel="nofollow author"', ob_get_contents() );
	else
		$output = str_replace( 'class="url fn"', 'class="url fn" rel="author"', ob_get_contents() );
	ob_end_clean();
	echo $output;
}
add_action('thesis_hook_post_box_top', 'custom_headline_catcher');
add_action('thesis_hook_before_post', 'custom_headline_catcher_end');

add_action('thesis_hook_before_teasers_box', 'custom_headline_catcher');
add_action('thesis_hook_before_teaser', 'custom_headline_catcher_end');

The final two lines of PHP add the Google rel=”author” markup to your teasers, too!