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.

I'm really trying to find a way or find a plugin (that works) that puts in different rel=author and/or rel=publisher attributes for a blog with multiple authors.

That way, in a Google SERP, an article I wrote might show up as:

Jason Weber Meta Title of that post
(my picture) Meta description of that post 

While another's post's SERP might look like this:

Tracy Smith Meta Title of Tracy's post
(Tracy's picture) Meta description of Tracy's post 

Does anybody have a suggestion for a plugin, hack, or fix that can accomplish this? Any guidance or suggestions would be greatly appreciated!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Well, you can try my plugin ;), but almost every SEO plugin includes this functionality now, and there are several plugins which are kind of dedicated to it.

If you want to code it yourself for whatever reason, all you need is basically to add a field in the user profile admin page in which the user google profile url, and use the data in the header

profile related code

add_action( 'show_user_profile', 'wase84176_user_fields' );
add_action( 'edit_user_profile', 'wase84176_user_fields' );

function wase84176_user_fields($user) {
  here should go some wrapper HTML to make it display nice 
  Enter your google profile URL <input id="wase84176_user_url" type="checkbox" value="<?php echo esc_attr(get_user_meta($user->id,'wase84176_user_url',true)?>" name="wase84176_user_url"> 
}

add_action( 'personal_options_update', 'wase84176_user_fields_save' );
add_action( 'edit_user_profile_update', 'wase84176_user_fields_save' ); 

function wase84176_user_fields_save( $user_id ) {

    if ( !current_user_can( 'edit_user', $user_id ) )
        return false;
    $opts = array();
    if (isset($_POST['wase84176_user_url']))
        update_user_meta( $user_id, 'wase84176_user_url', trim($_POST['wase84176_user_url']) );
    }
}

add the link in the header.

add_action('wp_head','wase84176_user_head');

function wase84176_user_head() {
  global $post;

  if (is_singular()) { // an author can reliable be set only for single pages
    $m = get_user_meta($post->post_author, 'wase84176_user_url',true);
    if ($m) {
        $data = get_user_meta($post->post_author,'wase84176_user_url',true);
        echo '<link href="'.esc_attr($data).'" rel="author">';
    }
  }
  if (is_author()) { // and on the author posts page
    $m = get_user_meta($post->post_author, 'wase84176_user_url',true);
    if ($m) {
        $data = get_user_meta($post->post_author,'wase84176_user_url',true);
        echo '<link href="'.esc_url($data).'" rel="me">';
    }
  }
}

Will not go into details why single pages get rel="author" while the author page get rel="me", I just felt it is more in line with the spec but the way google authorship works any of them should work

share|improve this answer
    
Hey, thanks a bunch for the response, Mark. I'm a relative WP Newb, learning on the fly. I finally got one of my blogs to show both rel=author and rel=publisher in G's Structured Data Testing Tool, but because there are a few guest authors, I wanted their pictures to show up in the SERPS if they authored the post. I think your plugin will do that -- even if the code needs to be modified. I'm definitely gonna give it a shot. Again, thanks a bunch for taking the time to read my question, and respond with all that information -- I'll definitely put it to use! –  Jason Weber Feb 2 '13 at 14:55
1  
It takes several days for google to show the pictures, and don't forget to tell your authors to add links to the site in the "contributor to" part of their profile –  Mark Kaplun Feb 2 '13 at 15:38
    
Yes, that's the part I always forget, no matter what domain I'm working on, Mark ... the easiest part -- adjusting you G+ profile. hehe ... Thanks again! –  Jason Weber Feb 2 '13 at 21:14

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.