If what you want is for this function to run once a day and loop through all matching posts (removing img
tags), I think this should do the trick:
<?php
function remove_images_form_past_posts() {
if ( get_transient('images_removed_from_past') )
return;
$args = array(
'post_type' => 'post',
'year' => 2013,
'monthnum' => 1,
'day' =>28,
'post_status' =>'publish',
'category' => 30,
'post_author' => 3,
'nopaging' => 1
);
$posts = get_posts( $args );
if ( $posts ) {
foreach ( $posts as $post ) {
$newcontent = preg_replace('/<img[^>]+\>/i', '', $post->post_content);
$newpost = array(
'ID' => $post->ID,
'post_content' => $newcontent
);
wp_update_post($newpost);
}
set_transient('images_removed_from_past',true, 60 * 60 * 24);
}
}
add_action('admin_init','remove_images_form_past_posts');