X

How to Add Google Authorship to WP

Snippets by IsItWP

Will adding verified Google Authorship increase your search rankings? Some people say “yes” and there’s only one way to find out. At the very least, it certainly looks good.



Add this code to your functions.php file. Paste your Google+ profile URL on your user profile (Google Plus field). And you’re done!

 
function add_google_plus_user_contact_field($contactmethods){
    // Add Google+ Author
    if (!isset( $contactmethods['googleplus']))
          $contactmethods['googleplus'] = 'Google Plus';
    return $contactmethods;
    }
add_filter('user_contactmethods','add_google_plus_user_contact_field',10,1);
    
function add_google_plus_author_url(){
    if (is_singular() ) {
          global $post;
          $googleplus_url = get_the_author_meta('googleplus', $post->post_author);
    
          if (!empty($googleplus_url)){
            $google_plus_author_markup = '<link rel="author" href="'.$googleplus_url.'"/>';
            echo $google_plus_author_markup;
        }
    }    
}
add_action('wp_head', 'add_google_plus_author_url');

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 9 best WordPress accordion plugins and how to create a contact form in WordPress.

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!