简体   繁体   中英

Bulk remove a word from all WordPress URLs

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.

如果您知道在其中定义了该URL的表和列,则可以运行下一个查询:

UPDATE 'table_name' SET 'url_column' = REPLACE('url_column', '-page', '');

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM