Fool rushes in…
-
I’m using the recently-released ‘Auto-Delete Posts‘ plugin. It does something incredibly useful for me, but appears to have a flaw. I’ve tried contacting the author but haven’t been able to reach him, so I’m (foolishly?) attempting to fix this problem myself.
This plugin searches for posts that are older than NOW minus an interval that we select using the Options interface. For instance, if we select an expiration date of 1 week, then any post older than NOW-1 week is deleted.
$query = "SELECT ID FROM $wpdb->posts WHERE post_date < NOW() - INTERVAL " . $expiration . " DAY";
$ids = $wpdb->get_results($query);
foreach ($ids as $id) {
if ('' == $id->ID) { continue; }
wp_delete_post($id->ID);
}
}Here is the problem: this query retrieves the id’s of WP static “pages” as well as individual posts. (The page data is still in the template file, of course, but you have to relink to it using Manage > Pages.)
How can I modify this query so that it selects posts only — and does not select “pages”?
Thanks for your help!
- The topic ‘Fool rushes in…’ is closed to new replies.