Skip to content

Instantly share code, notes, and snippets.

@lswilson
Last active August 29, 2015 13:58
Show Gist options
  • Save lswilson/9938267 to your computer and use it in GitHub Desktop.
Save lswilson/9938267 to your computer and use it in GitHub Desktop.
WordPress: SQL to migrate posts from a single category to its own custom post type
UPDATE wp_posts
inner join wp_term_relationships rel on wp_posts.id=rel.object_id
inner join wp_term_taxonomy tax on rel.term_taxonomy_id=tax.term_taxonomy_id
inner join wp_terms term on tax.term_id=term.term_id
set wp_posts.post_type='your_post_type'
WHERE
term.slug="category_name"
@jtsternberg
Copy link

This gist was justly gisted. mind blown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment