I have an issue I can't seem to fold a solution for. I'm looking for a way to mass remove the featured images of posts older than X amount of days. 150 days is my target but if I can set it to whatever all the better.
I've been working in mySQL to do this but it seems the meta_value is too complex for my limited knowledge of regex and I can't seem to overcome it. And what I need is for the featured image on posts older than X amount of days (150 target) to simply not be there anymore; not in the code, seen, etc...
Right now I'm trying to replace it with a placeholder.png but that's not necessary as long as the featured image can just not be there.
Anyone run into an issue like this? Anyone overcome it? Can anyone help me overcome it?
I've tried a few plugins but to no avail. If you have one you know works please let me know.
It's imperative that the ones removed be only 150 days or older and not anymore recently.
Thank you everyone!
p.s. I want to add that my overall goal is to remove featured posts and post images older than 150 days. Sure I can just remove the files physically from the server but the code is still there. I just cannot have that.
Here's what I'm doing to remove post images. Can it be modified to safely remove featured images or is there a better way?
(201[0-5]\/(?:0[1-9]|1[0-2])\/.*?\.(?:jpg|png|gif|jpeg)) to be replaced with placeholder.png
function wpdev_remove_featured() { $args = array( 'post_type' => 'post', 'date_query' => array( 'after' => date('Y-m-d', strtotime('-180 days')) ) ); $posts = get_posts($args); foreach($posts as $post) { delete_post_thumbnail($post->ID); } }