Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

in this page google help us to enable our profile image on google search list when some one search get results from our blog post.

my question not about how to do that ... like this link that closed ... but about the blog that has many authors that in the Google article i cant find anything about multi user authors and separation.(seperate them and linked their own posts to google result?)

how we can do that , with second solution ?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Author info is two steps:

  1. Link pages on your site to the Author's Google+ Profile, the easiest way being a rel="author" <link /> tag in the <head> section.
  2. Authors link the the site on their Google+ profile, the "contributes to" section (or whatever that happens to be called.

Step 1 has to do with WordPress. Step 2 is up to the author. A blog that has multiple authors is no different from one that has one. You just need to output the rel="author" tag on a per author basis. Which means you need to add a field to each user's page where they (or the site admin) can input a Google+ link.

Fortunatley this is really easy: hook into user_contactmethods to insert a new field into the contact methods area of the user form for Google+, then use the value there to output a rel="author" tag in the head section. Because it's per user (author) each individual post will have it's own rel="author" tags.

The example below is limited to singular pages (posts, pages, custom post types), but you could easily expand it.

<?php
add_filter('user_contactmethods', 'wpse83193_user_contactmethods');
/**
 * Adds a Google+ field to the contact methods area in the user's profile.
 *
 * @param   array $contact key => label pairs of contact methods
 * @return  array Same as the input: key => label pairs
 */
function wpse83193_user_contactmethods($contact)
{
    $contact['wpse83193_google'] = __('Google+', 'wpse');
    return $contact;
}

add_action('wp_head', 'wpse83193_output_contactmethods');
/**
 * Spit out the rel=author link tag in the <head> section.
 *
 * @uses    is_singular
 * @uses    get_user_meta
 * @return  void
 */
function wpse83193_output_contactmethods()
{
    if (!is_singular()) {
        return;
    }

    if ($rel = get_user_meta(get_queried_object()->post_author, 'wpse83193_google', true)) {
        printf('<link rel="author" href="%s" />', esc_url($rel));
    }
}

The above as a plugin.

There are also plenty of SEO plugins that do exactly what I showed above already built and ready to go.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.