简体   繁体   English

批量删除所有WordPress URL中的单词

[英]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 我已经将大约600页的页面导入到我的WordPress数据库中,并且大多数(不是全部)新URL的末尾都带有“ park”一词。

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. 我想批量删除该单词(及其前一个破折号-),以通过SQL查询或其他推荐方法进行更改。 Any advice for a safe way to change URLs inside a database would be greatly appreciated. 对于更改数据库内部URL的安全方法的任何建议,将不胜感激。

如果您知道在其中定义了该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/ 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. 注意:请记住,仅应对wp_posts表执行此操作,并在执行查询之前对数据库进行备份。

The slug is stored in wp_posts.post_name . 子弹存储在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! 我建议您在运行此查询之前备份您的WordPress数据库!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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