Multiple Authors

About

This plugin is intended for blogs where multiple authors collaborate on entries. It will keep track of who has edited the entry, and add them on as one of the listed authors.

Download

Instructions

  • Click the “Download” button and save it as a file named multiple-authors.php
  • Upload to your /wp-content/plugins/ directory.
  • Activate it from within the WordPress admin interface. From this point on, authors who edit posts that are not their own will be noted as an author.
  • In order to display these additional authors on the blog, edit your template and look for:
    <?php the_author(); ?>
    Edit it so that it reads: <?php the_author(); txfx_other_authors(); ?>

txfx_other_authors() takes 4 parameters, all optional, and in this order:

  1. $between (what separates the authors, defaults to ", ")
  2. $last (what separates the 2nd-from last and the last author, defaults to " and ")
  3. $before (displayed before the entire list)
  4. $after (displayed after the entire list)

Note that $before and $after only display if there are secondary authors.

Update: New in version 0.2! Instead of using the txfx_author_authors() function to display the other authors, you may use the advanced loop structure, which allows use of all author functions. The loop should look as follows:

<?php foreach ( txfx_all_authors() as $authordata ) : txfx_next_author(); ?>

<?php // author functions go here ?>

<?php endforeach; ?>

Sometimes you want to display things based on how many authors there are, or which author in the loop you are currently displaying. You can use the txfx_author_count() and txfx_author_number() functions for that. Like so:

<?php foreach ( txfx_all_authors() as $authordata ) : txfx_next_author(); ?>

<?php if (txfx_author_number() == txfx_author_count() && txfx_author_count() > 1 )
echo " and ";
} elseif (txfx_author_number() > 1) {
echo ", ";
} ?>

<?php the_author(); ?>

<?php endforeach; ?>

This will display a list like this: author1, author2 and author3

I’ve spent a lot of time writing this code and supporting it. If you derive some benefit from this code, please consider showing your gratitute in a more tangible
way. Thanks!

I have received $5.00 this month for my coding efforts.

Donate with PayPalAmazon.com Wishlist


94 Responses to “Multiple Authors”

  1. Michael |

    Just another great piece of code. THX

  2. Usayd |

    Thats great, i think i’ll give it ago. Thanks alot!

  3. Michael Jones |

    VERY cool. I’ve been looking for something like this. I’ll try it out and we’ll see what happens.

    One suggestion (and I don’t know how hard it would be) would be to have it where you could manually choose multiple authors, maybe with checkboxes on the post’s admin page.

    Just a thought. :)

  4. Mark (post author) |

    Michael,
    You can already do this, although not quite with the simplicity of a bunch of checkboxes. If you scroll down to the “Custom Fields” section of the post edit screen and enter in a key of other_author and a value of the author’s login name, they will be added on as an author. I’ll definitely consider adding an easier way of manually specifying other authors, however.

  5. Usayd |

    Hey, thats a great plugin thanks alot. I was wondering if there was any way you could make it compatible with the Coffe2Code Author Images plugin. I’m sure it wouldn’t be very hard but i’ve got them running together and although they both work for what they’re supposed to do, the Coffe2Code one doesn’t show the multiple authors whom have modified the Post, instead it just shows the initial author.

    Maybe you could modify the current coffe2code plugin and incorporate both of these things and release it as a seperate plugin?

    Thanks

    Usayd

  6. Michael Jones |

    Mark,

    I’ve never messed around with custom keys/fields, so I never knew you could do that. Thanks!!

  7. hmaster |

    I cant get this too work.My friend has a site and hes adde me as an author. I just want it to say “posted by him” or “posted by me” and im not sure if im editing it all right!

    i open wp.php and then i put in what it says and it doesnt show on the blog

    im using version 0.2 can any one help me out ?

  8. Mark |

    Hmaster,
    You do not need to use this plugin for that functionality. <?php the_author(); ?> will work just fine. This is just meant for cases where two or more authors edit the same post.

  9. hmaster5 |

    Yeh I already sorted it, thanks anyway :)

  10. Dave |

    Hi Mark,

    Is there a way to keep from automatically adding an author? For example, the site administrator needs to go into the post admin panel for whatever reason - the plugin automatically inputs the admin as an author and cannot be removed after changes have been made.

    Thanks for the reply - it’s a great plugin!

  11. jon |

    i’d like to second the request by dave (#14) to prevent automatic adding — this thing would be of great use to me with that option. thanks for the hard work!

  12. Mark (post author) |

    You can disable automatic adding of other authors by removing or commenting out these two lines at the very bottom of the plugin:

    add_action('edit_post', 'txfx_oa_add_author');
    add_action('save_post', 'txfx_oa_add_author');
    
  13. jon |

    thanks for the awesome news & speedy response mark - i’ll be giving this a whirl tonight for sure. thanks again!

  14. jon |

    sorry, just thought of a question — to add 1 extra author, i’d enter their name in a custom field called “other_author”, but how about adding 2 or more multiple authors? would their names just go in the same field, separated by commas? thanks

  15. Mark (post author) |

    Actually, you’d add multiple other_author fields (one at a time) each with one author login name.

  16. Ken-ichi |

    This looks great, but I don’t think it works with WordPress 2.0. Any plans for a 2.0-compatible version?

  17. Mark (post author) |

    I’ll definitely be updating it to work with WordPress 2.0, probably within the next week!

  18. yantar |

    it doesn’t work with my wordpress 2.0 :-( is it something wrong with me?

  19. Laurent |

    Hi,
    I will need this plugin to work with wordpress 2.0
    do you intend to release an update?

  20. Laurent |

    so far so good, seems to work in 2.0 now , no problem.
    No I have multiple authors for one post.
    Now I want to use the the_author_posts_link() functin with it. Unfortunatly I don’t get a result on the link for other_author , any Idea how I could get all posts of the other_autors ?

  21. Mark (post author) |

    You have to use the loop syntax… see the update above.

  22. Suspect |

    Hi,

    I’m using this plugin on version 2.0.2

    Everything works fine except when putting the extra code into the template.

    Like stated above, I enter the following code into the template:

    However, after this change, the page stops loading correctly right before this code.

    What am I doing wrong?

    In fact, what I need is something like this:

    Posted by: xxxxxx Edited by: xxxx and xxxx Last changes made by: xxxxx

    Thx in advance for your reply.

  23. Coyotech |

    This doesn’t work in wordpress 2.04 :( help please nothing shows up in admin panel after I activate it.

  24. Alejandro |

    Hey

    Plugin works great!

    One question? How can I make the output of the plugin linkable to the author’s posts?

    The author tag in my site (the_authors_post_link) outputs the author’s name linked to all his/hers posts.

    Is there a similar structure for your plugin?

  25. Alejandro |

    Silly me, I didn’t take time to try out the plug in before asking the above question and, what do you know, I answered it myself in the process.

    I was able to display both authors’ names linked, but, I can’t get a simple comma “,” or an “and” to display between them.

    This is the code I placed in my template:

    Any ideas?

  26. Alejandro |

    <?php foreach ( txfx_all_authors() as $authordata ) : txfx_next_author(); ?>

    <?php the_author_posts_linkr ?>

    <?php endforeach; ?>

  27. Sanjeev |

    This is a great plugin. I’ve been able to use it, but the second author’s url is the same as the first author’s. I think the “(get_the_author_url())” is outside the loop which causes this, but I am not sure how to change it. Here’s the code:

    Posted by:

    “>


    What I was trying to do was link each author to their respective url’s. Any help would be appreciated. Thanks.

  28. S G |

    Hi

    thanks a lot for the nice plug-in.

    There is a small problem though, when I click on an author’s name, posts he has written with other persons are not listed in his author archive!

    any ideas what has to be done?

  29. S G |

    I am sorry, I have found another small problem :-)

    If somebody puts the loop you propose to cycle through the authors twice in a page, the second time it doesnt work well! IF you have authors A, B and C the second time it forgets about author A and shows C, B and then C again! I would really apprecciate a fix for that…

  30. Roman Edirisinghe |

    Is there anyway someone could give me some pointers how to implement the loop code in the sandbox theme?

  31. Mosey |

    Does this work with 2.11? :D Thanks!

  32. Alison Moore Smith |

    I’m using your tip per #7. Could you tell me if THIS method also requires editing of my templates?

    I tried adding the others using other_authors, but they still don’t show up.

    Any help appreciated.

  33. snowcrash |

    Hello

    Really appreciate this plugin

    Is it possible to modify it so it only shows an additional author if added manually in the custom field.
    The reason why is that I and other editors often edit others members posts - how would I stop these names being automatically displayed.

    I tried looking at the code but couldn’t figure it out. Any help would be appreciated

    thanks

  34. snowcrash |

    Hello Again

    I actually find a small hack which enables only to add author manually

    http://fungibleconvictions.com/2007/01/24/multiple-authors-per-post-in-wordpress/

  35. Adam |

    Is there a way to select which authors can post that have other authors edit it?
    Because someone on my blog likes to start a lot of drafts. I would like to make it so he can only work on his posts.

  36. Jay Gilmore |

    I would like to make a suggestion and that is to use the display name for the reference for the plugin vs the login username.

    I have many users and it is a pain to have to remember all the login usernames but I have a handy-dandy drop down to use to remember who is an author all I have to do is check to see who is on the list and type the name exactly otherwise I have to print out a list of usernames or somesuch.

    Great plugin though!

  37. youtube |

    I would like to make a suggestion and that is to use the display name for the reference for the plugin vs the login username. ?

  38. manga |

    Trying to install this plugin and I´m having trouble finding where in my template I should put ”

    As if I do this all I get is a blank section…

  39. manga |

    Now I got the plugin to work…
    almost the way I wanted it. Now all I need is to add something that enables the “,” between the first and the second along with “and” between the second last and last author…

  40. Scot Hacker |

    I’m sure it would be a lot more work, but my feature request here would be to not use metadata at all, but to instead have the plugin replace the Author picklist in the post editor with a multi-select combo box or column of checkboxes.

  41. Scot Hacker |

    I’m having the same problem as Sanjeev, above (#37): If I have a main author plus an additional author entered via other_author, I get the main author outputted twice, with no reference to the other_author. Using WP 2.2.2 and the loop code as above. Any suggestions? Thanks.

  42. Scot Hacker |

    OK, realized why I was getting this behavior - my bylines are generated by a custom function. I had put the txfx loop in the function, but of course the function is only called once per story. I moved the loop out into the templates so that the function is called once for each other. D’oh!

    So that’s working now, but this leads to a separate problem: Each author’s name is linked to their author page, which presents a list of all their stories. But of course the story only appears in the story list for the “main” author. The stories loop (naturally) doesn’t pick up on the fact that the current author also authored stories for which they’re listed as other_author. This again points to the need to be able to select multiple real authors for a story, rather than using meta fields for this.

    But I guess that’s a whole WP architecture problem…

  43. Dennis Wurster |

    This plugin is a great start to precisely what I want.

    The downside at the moment is that if I perform a search using the name of any of the ‘other_authors’, the posts in which they share ownership don’t appear. Perhaps that’s not clear. Allow me to present an example:

    Authors A and B collaborate on a post, such that A is the author, and B is merely an entry in the post’s meta data as an ‘other_author’.

    When searching for posts written by A, the post shows itself properly.

    however

    When searching for posts written by B, the post will fail to appear.

    (This searching is within the administration area of WP 2.3)

    Clearly, there is a one-to-many relationship between authors and posts, when it would be more useful for it to be a many-to-many relationship.

    Since this has been marked as a WONTFIX by the WP Staff (here and here), I’m not sure what to do next.

  44. sanjay |

    Yes, this a great plugin, but I have the same problem as Derek.

    The second author B’s post’s don’t show up. (Though if the B does have another single authored post themselves, then all their posts show, included those co-authored as a second author)

    It’s rather disappointing that WP is still so single-author centered

  45. YouTube |

    Thanks for comment…:)

  46. michaeljubel |

    I have similar problem with S G. If I call the function twice in the same page, the first one works fine but the second one always “forgets” the main author.. for example the main author is A.. the first list will be A, B, C.. (that is okay).. but the second one is going to be C, B, C.. and if the first list is A, B, C, D, E.. the second one will be E, B, C, D, E.. there is something wrong with the variable..

    For your information, my page actually looks like this..

    —POST TITLE—
    By: Author A, Author B, Author C, and Author D

    —CONTENT—-

    Writers:
    – Author D: Author D is blablablabla.. (his/her profile)
    – Author B: Author D is blablablabla.. (his/her profile)
    – Author C: Author D is blablablabla.. (his/her profile)
    – Author D: Author D is blablablabla.. (his/her profile)

    the author list below the title is the first call.. it works fine.. but the author list below the content (the second call) has something wrong in it..

    the first list is called by this function:

    and the second one is called by this function:

    (author profile is here..)

    I’ve tried to find what is really wrong and I find this out.. I changed this…


    function txfx_other_authors($between=', ', $last=' and ', $before='', $after='') {
    global $post, $authordata;

    $other_authors = get_post_meta($post->ID, 'other_author');
    if ( count($other_authors) < 1 ) return;

    // initialize some vars
    $c = 0;
    $count = count($other_authors);

    // still here? time to loop through the authors
    echo $before;
    foreach ($other_authors as $author) {
    $c++;
    $authordata = get_userdatabylogin($author);
    if ($count == $c) {
    echo $last;
    } else {
    echo $between;
    }
    the_author();
    }
    echo $after;
    }

    into this….


    function txfx_other_authors($before='', $after=' and friends ') {
    global $post, $authordata, $temp;

    $other_authors = get_post_meta($post->ID, 'other_author');
    if ( count($other_authors) < 1 ) return;

    // initialize some vars
    $c = 0;
    $count = count($other_authors);

    // still here? time to loop through the authors

    echo $before;
    echo $after;

    }

    and the both of the list works fine BUT the first list only shows “Author A and friends”.

    So, definitely there is something wrong here:

    foreach ($other_authors as $author) {
    $c++;
    $authordata = get_userdatabylogin($author);
    if ($count == $c) {
    echo $last;
    } else {
    echo $between;
    }
    the_author();
    }

    and it conflicts with this:


    function txfx_all_authors() {
    global $post, $authordata, $txfx_authordata;

    // Load up the primary author
    $all_authors[0] = $authordata;

    // We’re on the first author
    $txfx_authordata['current'] = 0;

    $other_authors = get_post_meta($post->ID, ‘other_author’);
    if ( count($other_authors) < 1 ) {
    $txfx_authordata['count'] = 1;
    return $all_authors;
    }

    foreach ( $other_authors as $author ) {
    $all_authors[] = get_userdatabylogin($author);
    }

    $txfx_authordata['count'] = count($all_authors);

    return $all_authors;
    }

    The primary author variable is not loaded well..

    // Load up the primary author
    $all_authors[0] = $authordata;

    This is what exactly going on..
    e.g there is a main author and 3 other authors.
    FIRST CALL:
    -> main author (shown by wordpress default tag)
    -> second author ($authordata=author[1])
    -> third author ($authordata=author[2])
    -> fourth author ($authordata=author[3])

    the last variable is “transferred” to the second call..

    SECOND CALL:
    -> main author (shown by txfx_all_authors(), $authordata=author[3])
    -> second author ($authordata=author[1])
    -> third author ($authordata=author[2])
    -> fourth author ($authordata=author[3])

    that’s why the second list is D, B, C, D.. BUT, even though so, i’m not really a PHP guy so i do not know to fix it..

    HELP! :D

  47. michaeljubel |

    anyway i forget some ‘code’ tags within my last comments.. so the php code is kind a mess.. and i think it’s a bit difficult to read.. but i hope get what i meant.. and i really thank you if you edit my comments in you wordpress dashboard and add some ‘code’ tags in it.. thx! :D

  48. Max Shay |

    Hi, just a question. I’m having a couple problems with this plug-in. I’m calling the other authors via:

    My first problem, is that ‘ and ‘ is not being shown between authors. I read through the comments here, and didn’t find a solution to this, maybe I just missed it.

    Second, when a second author is added to the post. The post does not show up when you click on that author’s link. It appears that although their name is being displayed, the post isn’t attributed to their “user”. Is there any fix for either of these? I appreciate your time, thanks

    -MCS

    P.S. Oh, and also, the multiple authors thing is REALLY throwing off my RSS reed. Again, any help or direction I can get is much appreciated, thanks!

  49. Max Shay |

    Nvm, figured out the “and” problem, and the RSS bug. Still stuck on how to give BOTH authors credit for the post. I have it so that each author’s name is linked to their posts. I need this post to be credited to both authors. Thanks!

  50. Weston Ruter |

    I’ve written a new WordPress plugin called “Co-Authors” that is inspired by this plugin. It is more efficient in that it stores the user ID instead of the user nicename.

    Features include:

    1. listing all co-authored posts in an author’s posts page and feed
    2. extending the “Post Author” box in the interface sidebar so that adding new co-authors to a post is seamless
    3. providing new template tags which make it easier to display each co-author with a link to their posts page and other items
    4. including a modified version of wp_list_authors that takes into account posts with co-authors
    5. defining a co-author iterator class that can be used for stepping through all of a post’s co-authors

    See more on the Co-Author Plugin page.

  51. Scot Hacker |

    Weston - Looks *perfect* and should address all of the issues coming up for news publications using WP - thanks for posting that.

  52. Letsdown.net |

    This is really a good code.Thank you very much.Good work.

  53. youtube |

    Michael,
    You can already do this, although not quite with the simplicity of a bunch of checkboxes. If you scroll down to the “Custom Fields” section of the post edit screen and enter in a key of other_author and a value of the author’s login name, they will be added on as an author. I’ll definitely consider adding an easier way of manually specifying other authors, however.

  54. youtube |

    VERY cool. I’ve been looking for something like this. I’ll try it out and we’ll see what happens.

  55. facebook |

    You do not need to use this plugin for that functionality. will work just fine. This is just meant for cases where two or more authors edit the same

  56. zeytin |

    thanks everthingds

  57. Forum |

    Hi.. Good Thanks Admin

  58. Roman Pixell |

    is there a way to make the other author names clickable? the first author is linked to a listing of all entries that he or she has written. i would like have the same functionality even if there are multiple authors…

Leave a Reply