Quickly Batch Change the Author of WordPress Posts

Posted on

There could be many reasons why you would want to change the author of a WordPress post. It could be as simple as having spelt the name wrong and wanting to correct it. Or maybe they wish to be known via a pseudonym. More frequently however it’s because the individual has stopped writing for the blog and you wish to change the author of their posts to the admin or someone else. In any case, it’s quite easy to change the author of any single WordPress post. It’s merely a question of setting the right metadata. You can do this directly in the WordPress post editor, or you can make quick changes to several of them at the same time via the “Quick Edit” functionality.

But what if you want to make changes to hundreds of posts at once? Moreover, suppose you wish to change the post attributions of several authors at the same time? For a well established blog having hundreds or even thousands of posts, it’s not feasible to manually go and change the author individually. Fortunately, with a little bit of database tweaking, we can accomplish this with a single SQL query. But first, let’s look at how to quickly modify a WordPress post author within the WordPress interface itself.

Change One or a Few WordPress Authors

If changing a couple of post authors is only going to take a minute or so, it’s not worth the hassle and risk of messing around with the MySQL backend database. To do this, simply visit the list of posts after logging into WordPress and find the one whose author you want to change. When you hover over the post with your mouse you should see a series of links appear at the bottom. One of them will be called “Quick Edit”.

quick edit

Clicking this allows you to immediately change the metadata of the selected post without actually having to open up the post editor screen. From this interface, you can change the title, categories, tags – and yes, the author. As shown in the screenshot below, simply click the drop-down box for the author field and select the one you want instead.

change author

Note however that you can only do this one at a time. There are a few WordPress plug-ins that allow the “quick editing” functionality on WordPress batch posts though. But let’s look at how to go one step further and change a whole swathe of WordPress authors at the same time.

Change via SQL

For this operation, you need to have access to your WordPress MySQL database either through a database client on your local computer or through something like the phpMyAdmin interface through your cPanel account. In case you don’t know how to access phpMyAdmin, you can check out some of the screenshots in an earlier tutorial I wrote about resetting the WordPress username and password.

Once you have your database interface open, go to the SQL section and run the following query:

SELECT ID, display_name FROM wp_users;

This will give you a list of current authors on your WordPress blog, but more importantly, it will tell you their IDs.

get author ids

The ID is the key value that you’re going to change. Write down the ID of the old author name as well as the ID of the new one. Now we’re going to write an SQL query to simply change all instances of the old author ID to the new one. In the same place where you wrote the first SQL query, create a new one by typing in the following:

UPDATE wp_posts SET post_author=id_new_author WHERE post_author=id_old_author;

Don’t forget to replace the areas marked in bold with the new and old author IDs you noted down just one step earlier. Executing this will immediately change the author attribution of all posts with the old author to the new one. Keep in mind that this is a very powerful tool but it also dangerous. Always be sure to take a backup of your WordPress database before you make any changes, or verify that your web host has an automatic backup available. You can’t be too careful when it comes to safeguarding your backend MySQL database.

And there you have it – a simple way to modify WordPress authors in the hundreds or even the thousands if necessary with just a single MySQL query in an instant.

Leave a Reply

Your email address will not be published. Required fields are marked *