[WordPress] 特定のカテゴリに属する投稿を任意のカスタム投稿タイプに変換する SQL

タイトルで言い切ってるシリーズ
カテゴリ ID 4 に属する投稿を、カスタム投稿タイプ photo に

— カテゴリー 4 の投稿を、カスタム投稿タイプ photo に
update wp_posts
set post_type = 'photo'
where post_type = 'post'
and exists
(select object_id
from wp_term_taxonomy as t
inner join wp_relationships as r on t.term_taxonomy_id = r.term_taxonomy_id
where t.term_id = 4
and r.object_id = wp_posts.ID);

Posted

in

by

Tags:

Comments

コメントをどうぞ