Skip to content

Backgrounds

How-to Guides

Technical References

Add guest bylines to your content with Co-Authors Plus

Co-Authors Plus is a plugin maintained by WordPress.com VIP which makes it easy to assign one or more bylines to a post. With the guest authors feature, you can assign a byline to content without having to create a corresponding WordPress account. If your theme is using the appropriate template tags, you can create guest bylines without any additional configuration.

Creating or editing guest authors

On WordPress.com VIP, guest authors can be created and managed under “Users” -> “Guest Authors”.

Each guest author can have many of same fields a normal WordPress user would typically have, including display name, email address, and website. You can assign a featured image in order to override the avatar typically associated with the email address.

Once you’ve created your guest author, their byline can be assigned to a post using the normal Co-Authors Plus interface.

Details for developers

Incorporating new profile fields

The guest authors feature of Co-Authors Plus was written with extensibility in mind. The default set of profile fields can easily be manipulated using accessible filters. If you want to place your field in one of the existing post meta boxes, it can be as simple as the following example:

<php

/**
 * Add a "Google Plus" field to Co-Authors Plus Guest Author
 */
add_filter( 'coauthors_guest_author_fields', 'capx_filter_guest_author_fields', 10, 2 );
function capx_filter_guest_author_fields( $fields_to_return, $groups ) {

	if ( in_array( 'all', $groups ) || in_array( 'contact-info', $groups ) ) {
		$fields_to_return[] = array(
					'key'      => 'google_plus',
					'label'    => 'Google Plus',
					'group'    => 'contact-info',
				);
	} 

	return $fields_to_return;
}

Then, for use on the frontend, the new field is automatically loaded onto the $coauthor object.

Migrating users to guest authors with wp-cli

If you’re performing a migration of users to co-author guest authors, there are a couple of helpful wp-cli commands packaged with the plugin:

  • wp co-authors-plus create-guest-authors will create guest authors for all of your existing users
  • wp co-authors-plus assign-user-to-coauthor will then assign all of the posts associated with old user to your new guest author

So, the steps to migrate all of your users/authors to your WordPress.com VIP site would include:

  1. Install the Co-Authors Plus plugin on your staging site.
  2. Run the create-guest-authors CLI command to create the Guest Authors automatically.
  3. Perform an export from your staging site and save the resulting WXR file. The WP-CLI guest authors will be included in this export.
  4. Create a mapping CSV file for editorial users who require real logins from their login on the staging site to their login on the production site (these may or may not be be the same). The CSV file format is as simple as:
johnsmith, johnsmithwp
janesmith, janesmith
johndoe, johndoe123

Send us the WXR and mapping CSV, and we’ll run the import for you. While Co-Authors Plus will bring over all the bylines, we’ll use the mapping CSV to preserve the bylines for users with real logins. Have your team QA the imported authors.

Last updated: April 09, 2021