Multiple authors per post in Wordpress

Over on an academic journal site I’ve been setting up, I needed a way to assign multiple authors for a single post. Tempus Fugit developed a plugin to do just that, except it makes the assumption that anyone who edits a post should be listed as an author—true for blogs, not true for a site with editors posting others’ work. Here’s a simple fix, though, for anyone using Tempus Fugit’s multiple authors plugin…

In the plugin’s php file, delete the function that equates a post editor as an author:

function txfx_oa_add_author($post_ID) {
global $wpdb, $userdata;

if ( !$userdata ) get_currentuserinfo(); // shouldn't be needed, but can't hurt

$main_author = $wpdb->get_var("SELECT `post_author` FROM $wpdb->posts WHERE `ID` = '$post_ID'");

if ( $userdata->ID == $main_author ) return $post_ID; // the person who created the post is editing it... do nothing

// if we're still here, it must be a new author, so see if they are already logged as an author on this post
if ( $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = 'other_author' AND post_id = '$post_ID' AND meta_value = '$userdata->user_login'") ) return $post_ID;

// if we're STILL here, it's time to add this author
add_post_meta($post_ID, 'other_author', $userdata->user_login);

//and we're done
return $post_ID;

}

And at the very bottom of the file, to keep the file from breaking, delete the commands to add that now-ignored editor as an author:

add_action('edit_post', 'txfx_oa_add_author');
add_action('save_post', 'txfx_oa_add_author');

Done and done! Adding an author is manual now—you just add a custom field called “other_author” and type in the second (or third or fourth) author’s name in the “Value” box. And so long as it matches the name of a registered user, that person will be duly added as an author to the post.


4 Responses to “Multiple authors per post in Wordpress”

  • Bart Says:

    Is it possible to only comment out the two add_action lines at the bottom to accomplish this, without needing to mess with the function?

    You should check this post in Firefox. Only the first two lines of the function are formatted as code, the other lines look like the rest of your post (because you have a closing P tag before your closing tag).

  • Scot Hacker Says:

    Is it possible to only comment out the two add_action lines at the bottom to accomplish this, without needing to mess with the function?

    Bart, that in fact exactly what the plugin author recommends as the best way to handle this on his own site – just comment out the last two lines – no need to mess with anything else in the function.

  • Jaap Says:

    Is the plugin still available? txfx.net/ appears to be down…

  • Dennis Wurster Says:

    I need to add this functionality for a new WP site, and while the plugin does work, it shoves the subsequent authors into fields called ‘other_author’. This is great, until you want to do a search to see what those other_author’s have written. Doing so presents an empty set.

    Clearly, the solution would be to create a lookup table that contains post-IDs and author-IDs, but the problem is trying to assign multiple authors to a post. What you /want/ is to tick a checkbox next to the name in a list of authors, not to have to type it in manually.

    Are there *any* CMSes out there that support multiple authors per post, out-of-the-box?

Leave a Reply