How to: Change author attribution on all posts at once

Some bloggers makes the mistake to write their first posts under the name “admin”, until they realize that it’s absolutely not personal. But then, modifying author attribution on each post takes a lot of time. Happilly, here’s a recipe to batch modify author attribution.

To achieve this recipe, we'll use phpmyadmin and the SQL language. As the following commands will modify your WordPress database, don't forget to create a backup before running any command throught phpmyadmin.

The first thing to do is getting the IDs of WordPress users. Once logged in phpmyadmin, insert the following SQL command:

SELECT ID, display_name FROM wp_users;

Right now, phpmyadmin displayed a list of WordPress users associated with their IDs. Let's say that NEW_AUTHOR_ID is the ID of the "new" author, and OLD_AUTHOR_ID is the old author ID.

UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID;

That's all. Once this last command has been run, all posts from the old author now appears to have been written by the new author.

20 Responses

Oct 29 2008 08:15

Thanks a lot for the recipe, was looking a for a solution, having the same problem.

Oct 29 2008 08:47

That’s easier than I thought it would be :)

Oct 31 2008 06:05

How about changing Page (not post) category automatically like changing poster name explained above? i.e. changing from “uncategorized” to “info”.

Thanks

Nov 02 2008 04:45

Any idea of how to do this in a WPMU setting? I’ve consolidated a few blogs into a single WPMU install, but when I imported the posts, I imported them all as “admin”. Each blog has a different author, but all are “administered” by admin.

What sort of SQL magic would I use to select only admin’s posts from a certain blog? I suppose it would involve a WHERE clause indicating the BLOG_ID, but I wouldn’t know how to test it without killing everything in the process

Nov 02 2008 05:01

That was actually delightfully simple. WPMU keeps all of the blogs separated into their own tables, so to edit all the posts for a certain blog you just replace “wp_posts” with “wp_N_posts” where N is the BLOG_ID of the blog you want to fix up.

Thanks for the recipe!

Mar 23 2009 21:55

Thank you so much! I’m designing a site that’s importing from Blogger, but unfortunately I was labeled as the author of all the posts instead of the blog owner. This was a quick fix (there were over 900 posts!).

Dec 18 2009 23:57

Thanks so much for this…exactly what I was looking for!

Andy

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required