How to auto remove empty post using wp_schedule_event
-
I’m trying to make a simple plugins to remove empty post every hour or day using wp_schedule_event to make it auto.
I’m already test it activation and deactivated plugins with no problems. The problems is the plugin not working to remove empty post.
register_activation_hook(__FILE__, 'my_activation'); add_action('my_hourly_event', 'do_this_hourly'); function my_activation() { wp_schedule_event( time(), 'hourly', 'my_hourly_event'); } function do_this_hourly() { // do something every hour $wpdb->query('DELETE FROM wp_posts WHERE post_content=""'); } register_deactivation_hook(__FILE__, 'my_deactivation'); function my_deactivation() { wp_clear_scheduled_hook('my_hourly_event'); }Reference:
– codecorner.galanter.net/2009/12/11/wordpress-mu-delete-empty-posts/
– stackoverflow.com/questions/8734635/how-can-i-automate-a-sql-query-via-phpmyadmin
– codex.ww.wp.xz.cn/Function_Reference/wp_schedule_eventThank you in advance,
zonpro
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘How to auto remove empty post using wp_schedule_event’ is closed to new replies.