Reputation: 5903
I've imported about 600 pages into my WordPress database and most (not all) of them have the word "park" at the end of their new URL's
domain.com/awesome-park/
I would like to bulk remove the word (and its previous dash - )change them via SQL query or other recommended method. Any advice for a safe way to change URLs inside a database would be greatly appreciated.
Upvotes: 0
Views: 330
Reputation: 12485
The slug is stored in wp_posts.post_name
. So the following should work (this from the first answer above):
UPDATE wp_posts
SET post_name = REPLACE(post_name, '-park', '')
WHERE post_name REGEXP '-park$';
I do recommend backing up your WordPress database before running this query!
Upvotes: 0
Reputation: 634
This simple plugin can do the job.
https://wordpress.org/plugins/search-and-replace/
Note : Remember you should only do this for wp_posts table and take a backup of your database before executing the query.
Upvotes: 1
Reputation: 1801
If you know the table and column where this url has been defined you could run next query:
UPDATE 'table_name' SET 'url_column' = REPLACE('url_column', '-page', '');
Upvotes: 1