sql批量添加、修改、删除WordPress自定义字段命令备忘

批量删除包含某个自定义字段指定内容的文章

DELETE 'wp_posts' FROM 'wp_posts','wp_postmeta' WHERE wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = '自定义字段_value' AND wp_postmeta.meta_value LIKE '%指定内容%'


批量修改自定义字段名称

UPDATE 'wp_postmeta' SET 'meta_key'='新的自定义域名称' WHERE 'meta_key' = '旧的自定义域名称';


批量追加新的自定义字段和值

insert into wp_postmeta (post_id, meta_key, meta_value)
select ID, '新自定义字段', '自定义字段值' from wp_posts where post_type = 'post';


删除自定义字段

DELETE  FROM wp_postmeta WHERE meta_key = "自定义字段名称";