admin管理员组文章数量:1193817
I have hundreds of posts whose titles are of the form XmY
, where X
and Y
are natural numbers, for example 18m324
.
I'd like to replace m
with p
in all post titles and slugs, while keeping X
and Y
unchanged. How to do it in phpmyadmin?
UPDATE wp_posts
SET post_title =
REPLACE(post_title, 'm' , 'p')
WHERE post_type = 'post' AND post_status = 'publish';
This code should replace in the titles, but what about the slugs?
I have hundreds of posts whose titles are of the form XmY
, where X
and Y
are natural numbers, for example 18m324
.
I'd like to replace m
with p
in all post titles and slugs, while keeping X
and Y
unchanged. How to do it in phpmyadmin?
UPDATE wp_posts
SET post_title =
REPLACE(post_title, 'm' , 'p')
WHERE post_type = 'post' AND post_status = 'publish';
This code should replace in the titles, but what about the slugs?
Share Improve this question edited Nov 5, 2019 at 6:09 sound wave asked Nov 5, 2019 at 5:44 sound wavesound wave 2151 gold badge3 silver badges15 bronze badges1 Answer
Reset to default 1Slugs are saved in the very same table but in the post_name
column. So your query would look like this:
UPDATE wp_posts
SET post_name =
REPLACE(post_name, 'm' , 'p')
WHERE post_type = 'post' AND post_status = 'publish';
By the way, I'd suggest you to use $wpdb->posts
instead of just wp_posts
( then it would be compatible with different prefixes, but it's not important if it's just a "local" script )
本文标签: mysqlReplace a character in all post titles and slugs
版权声明:本文标题:mysql - Replace a character in all post titles and slugs 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738492422a2089783.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论