lickedone
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: edit / change author attribution on many posts at once?Hey guys, I found this thread and I want to share with you my solution. It is not for beginners, I’m afraid, so be forewarned. This involves using SSH to connect to your host, and this solution may not work with all web hosts. You are also going to need your database name, username, and password, which you can find in the root of your WordPress in the file wp-config.php. At the very top of that file, you’ll see some define statements with your DB info.
The first step is the make sure you have added the new user you want to change your old post’s author to. This is done within WordPress Admin > Users.
Now it’s time to SSH into your web host. My favorite SSH client is PuTTY. Once logged in, enter the command (replace DB_USER with the username you found in wp-config.php):
mysql -u DB_USER -p
Then, it will ask for your password, so enter the password you found in wp-config.php.
If you have done this correctly you should see a message that says
Welcome to the MySQL monitor.
along with some other info, and your command line will change tomysql>
. If this hasn’t happened, you’ve either done something wrong, or perhaps your webhost doesn’t allow mysql access through SSH.OK. Now enter this command to select the correct database (replace DB_NAME with the database name you found in wp-config.php, and don’t forget the trailing semicolon!):
use DB_NAME;
Now enter this command to show the users of your blog. This could potentially be a problem if you have a lot of users, I don’t so it wasn’t a problem for me.
SELECT ID, display_name FROM wp_users;
This will spit out some info. Take note of the ID of the user you want to change from (in my case it’s “admin”, and from now on I will refer to the ID as FROM_ID) and the ID of the user you want to change to (in my case it’s “Jason”, and from now on I will refer to the ID as TO_ID).
Up until this point, you have not made any changes to your database. But this final step here involves permanently editing your database. Proceed with caution. Backup your DB if you know how or if your web host provides an option to do so. This command will change your post author to your chosen new post author. Remember to replace FROM_ID and TO_ID with the ID’s you found in the previous step.
UPDATE wp_posts SET post_author=FROM_ID WHERE post_author=TO_ID;
If you’ve done everything correctly, you should now be able to go to your WordPress and see that all of your authors have been changed!