Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created December 29, 2011 23:17
Show Gist options
  • Save kovshenin/1536654 to your computer and use it in GitHub Desktop.
Save kovshenin/1536654 to your computer and use it in GitHub Desktop.
Change the year of all posts in a particular category to 2012
UPDATE wp_posts AS p
JOIN wp_term_relationships AS tr ON tr.object_id = p.id
JOIN wp_term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
JOIN wp_terms AS t ON tt.term_id = t.term_id
SET p.post_date = REPLACE(p.post_date, YEAR(p.post_date), 2012)
WHERE t.slug = 'my-category-slug' AND tt.taxonomy = 'category';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment