Skip to content

Instantly share code, notes, and snippets.

@aschweigert
Last active February 3, 2016 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aschweigert/9dd8391d7c47cbe11c80 to your computer and use it in GitHub Desktop.
Save aschweigert/9dd8391d7c47cbe11c80 to your computer and use it in GitHub Desktop.
set featured images to false before X date
drop temporary table if exists post_ids;
create temporary table if not exists post_ids
select ID from wp_14_posts
where post_status = 'publish'
and post_type = 'post'
and post_date < '2016-02-03 00:00:000';
delete wp_14_postmeta from wp_14_postmeta join post_ids
on wp_14_postmeta.post_id = post_ids.ID
and wp_14_postmeta.meta_key = 'featured-image-display';
insert into wp_14_postmeta (post_id, meta_key, meta_value)
select ID, 'featured-image-display', false
from post_ids;
/* to check your work
select * from wp_14_postmeta a
right join post_ids b
on a.post_id = b.ID
and a.meta_key = 'featured-image-display';*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment