Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Created November 28, 2012 04:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/4159068 to your computer and use it in GitHub Desktop.
Save wokamoto/4159068 to your computer and use it in GitHub Desktop.
[WordPress] 特定のカテゴリに属する投稿を任意のカスタム投稿タイプに変換する SQL
-- カテゴリー 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment