Is there a way to bulk update permalinks through the database? cause I have like 20k posts and all I want to do is add a prefix to the permalink. I could just manually update but that's too tiresome for 20k posts.

For example if post url is http://example.com/post-1 I want to change it to http://example/pre-post-1

  • 2
    Permalinks are not stored in database. Do you maybe mean post slugs?
    – gmazzap
    Oct 12, 2014 at 3:44
  • If you're unsure, please post a specific example of what you need to do. I made the mistake of assuming this was a question about a database search and replace for hard coded links and flagged it as off topic. I should have asked first, so sorry if I was mistaken!
    – iyrin
    Oct 12, 2014 at 4:22
  • 1
    @RyanLoremIpsum, I think you should be able to remove the close vote, just click it again and it should give you the option. Oct 12, 2014 at 5:39
  • @G. M Yes I mean post slugs
    – Ruriko
    Oct 12, 2014 at 9:00
  • @Ruriko Please always add additional info as edit to your question.
    – kaiser
    Oct 12, 2014 at 14:09

1 Answer 1


Try this query, remembering to change out your_posts_table with the proper name in your database. Using CONCAT, you can add any number of strings, just pass post_name to add your changes before/after.

update your_posts_table
set post_name = CONCAT('pre-', post_name)
  • More info on MySQL CONCAT
  • Note: Use a WHERE clause if you only want to update specific posts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.