Content Marketing, Search Marketing, WordPress

Enable Authorship and Publishing Link in WordPress

I keep telling folks I’d share how we’re integrating authorship microdata to produce search result rich snippets. It’s working well for our clients in increasing their SERP CTRs) so I figured I’d document it here for WordPress sites.

There are two pieces to this… and the two elements are not related. The authorship data is now being displayed in Search Engine Results Pages. I have not seen publisher info displayed yet… but I’m sure it will be!

Publisher

Google Plus now has a verification system where a publisher of a site can point to their Google+ page. By adding the following code in our theme’s functions.php page, we’ve added a section to our WordPress Administration general settings where we can paste our Google+ Page URL:

function social_settings_api_init() {
add_settings_section('social_setting_section', 'Social Sites on the Web', 'social_setting_section_callback_function', 'general');
add_settings_field('general_setting_googleplus', 'Google Plus Page', 'general_setting_googleplus_callback_function', 'general', 'social_setting_section');
register_setting('general','general_setting_googleplus');
}
add_action('admin_init', 'social_settings_api_init');

function social_setting_section_callback_function() {
echo '<p>This section is where you can save your social sites where readers can find you on the Internet.</p>';
}

function general_setting_googleplus_callback_function() {
echo '<input name="general_setting_googleplus" id="general_setting_googleplus" type="text" value="'. get_option('general_setting_googleplus') .'" />';
}

The next step is to publish the publish link on every page on the site outside of your single blog post pages. So, in our header.php, we add the following code:
<?php if(!is_single()) { ?><link href="<?php echo esc_attr(get_option('general_setting_googleplus')); ?>" rel="publisher" /><?php } ?>

Authorship

Authorship is a little more in-depth, especially if you have a multi-author blog like ours. Basically, we want all of our pages that authors write to display their Google+ profile data in search engine results. To get this down, I had to go to the master himself, Joost de Valk and read up on his rel=”author” post.

The first step is to override WordPress settings and allow anchor tags to be published with the appropriate rel element. Within functions.php, add the following code:

function yoast_allow_rel() {
global $allowedtags;
$allowedtags['a']['rel'] = array ();
}
add_action( 'wp_loaded', 'yoast_allow_rel' );

The next step is to add code to functions.php that adds a field to your User Profile page where the authors can fill out their Google+ URL:

function yoast_add_google_profile( $contactmethods ) {
// Add Google Profiles
$contactmethods['google_plus_profile'] = 'Google Plus Profile URL';
return $contactmethods;
}
add_filter( 'user_contactmethods', 'yoast_add_google_profile', 10, 1);

Now that you’ve got the field in there, you’re going to have to add an author link to every page that will point to your author content, like single.php, index.php, author.php and archive.php. Within those template pages, display the author link along with the rel=”author” and that link should point to your author.php profile page:

<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author"><?php get_the_author(); ?></a>

Within your author.php page, you’re going to want to display the profile information along with a rel=”me” link that points back to your Google Profile page:

$google_plus_profile = get_the_author_meta( 'google_plus_profile' );
if ( $google_plus_profile ) { echo '<p><a href="' . $google_plus_profile . '" rel="me"><img src="http://www.google.com/images/icons/ui/gprofile_button-32.png"></a></p>'; }

You tired yet? Don’t be… next step is to actually add a contributor link back to your author page within Google Plus:

Ok… now your author links are pointing to your author page, your author page is pointing to your Google Plus profile, your Google Plus profile is pointing to your author page. Do you see how we’ve got the entire circle covered here? One last step…

Use the rich snippets tool and actually verify that your rich snippets work okay! Test it on your root domain and your single post pages.

And now put in your domain and give it a shot:

Last note… all of this works pretty good, but not all the time. Sometimes I notice the rich snippets tool gives me an error and other times I see where rich snippets test fine, but it takes a few weeks to see them in search results. Either way, it’s a modification worth doing! Keep in mind that, since we did all of this within our theme that a new theme would require us to implement it all over again!

11 Comments

  1. 1

    Apparently my current theme doesn’t have an author.php file. Yet, my author URL does appear and render fine. I seemed to have gotten everything installed following your steps, but the rich snippet tool produced errors of the following:

    publisherlinked Google+ page = https://plus.google.com/118248936539718757580Error: This page does not include verified publisher markup. Learn more. Warning: Both rel=”publisher” and rel=”author” are present on the page. You should put rel=”author” on content pages and rel=”publisher” on your home page only (unless this is the home page of a single author site). authorlinked author profile = http://www.bnpositive.com/blog/author/bnpositive/
    Error: Author profile page does not have a rel=”me” link to a Google Profile. Learn more. 

    • 2

      @bnpositive:disqus You can make an author.php file fairly easy by copying the archive.php file and renaming it to author.php (sometimes there’s some cleanup to do to pull out category name headings, etc.) but it’s a good idea to have an author page.  I typically publish folks bio and photo on that page.
      I went to your Google+ page and you don’t have a link in the contributor section that points to your author page at bnpositive.  Also, are you trying to do an author link or a publisher link?  Your author page on bnpositive seems to have a Google+ page link on it.  An author page should point to your personal page, a publisher link should point to your Google+ page.

      • 3

        From my understanding I want a PUBLISHER link on all the non-post PAGES for my website that would direct to the Bnpositive Communication and Design Google+ Page. Then, for all the post pages that I write, I want a AUTHOR link on those pages that would reference my personal Google+ Page correct?

      • 4

        I just looked at my personal Google+ page and it does provided a contributor link to my author page on my blog. Should I have the same done on my Google+ Page as publisher?

      • 7

        Okay, I need to get an author.php page developed, but I’m thinking I’ll hold off until I decide what new theme I may be choosing for the site. Sounds like I need to get some time with you and buy you some coffee very soon!

  2. 8

    Hello, not sure if you’re still checking this, but – I got my rich snippets to say “Verified: Publisher markup is verified for this page.” but the image isn’t showing up in the rich snippet tool. My authorship works great on post links, but for my home page there’s no image and it just says that it’s verified. Do you know why this may be?

    • 9

      @twitter-509747237:disqus if you just modified them, you’re going to have to give them a few weeks to show up.  As well, we’ve seen them show up and disappear once in a while.  It appears that it’s a work in progress with Google.

      • 10

        Thanks for the response 🙂 I know it’ll take some time to show up in SERPS, but I’m concerned that it’s not showing up in the preview for the Rich Snippet Testing Tool.. in your tutorial you can see your company logo in the testing tool and I’m not seeing it, only that it’s verified. I guess I’ll wait it out for a couple weeks to see if I can get it to display in the RSTT, but if it never does, then I don’t know where I went wrong (not in a rush for it to show up in SERPS as it took my authorship about 3 weeks for that, but always showed up right away in the testing tool). Thanks again for the feedback.

        • 11

          @twitter-509747237:disqus Interesting! It appears they removed the publisher link snippet from showing the logo.  That stinks!!!  I was hoping they would begin publishing that in the SERP.  Your author link is good to go, though!

Leave a Reply