• Klaymen

    (@klaymen)


    I have a lot of articles assigned to Author 1 and I need them to be assigned to Author 2. How could I do this? I can’t waste my time in the admin panel changing them one by one, even with the quick edit function, so maybe a simple SQL query I can run? Some help?

Viewing 6 replies - 1 through 6 (of 6 total)
  • brandonzundel

    (@brandonzundel)

    If it’s all of their articles, you could remove author 1, and attribute all their content to author 2. That’d be the quickest way without messing with the database directly.

    Thread Starter Klaymen

    (@klaymen)

    Thank you for your reply, but I don’t want to delete that user… as it is the used I log in with. It’s the admin user. I have “Mysite User” and “Mysite”.. and I need all the articles to be posted under “Mysite”, if possible.

    catacaustic

    (@catacaustic)

    You’d need to do it with an SQL query.

    As a (very rough and not at all tested) example…

    UPDATE wp_posts -- Make sure to set your own table prefix here
    SET post_author = 2  -- The new author ID
    WHERE post_author = 4;  -- The old author ID

    That will transfer every post created by the user ID 4 to the user ID 2.

    Just remember that you should always take a backup of your database before doing any manual changes like this, just in case something bad does happen.

    Thread Starter Klaymen

    (@klaymen)

    Thank you so much!
    Then in the SQL query field in cPanel I would need to use this:

    UPDATE wp_posts SET post_author = 2 WHERE post_author = 4;

    right? Correct me if I’m wrong. Obviously changing the fields as you said (and making a db backup before).

    catacaustic

    (@catacaustic)

    Yes, that’s correct.

    Thread Starter Klaymen

    (@klaymen)

    That worked, thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change author via SQL query’ is closed to new replies.