Created
February 3, 2015 22:31
-
-
Save bigdawggi/1d58d946bf2f00b34b9d to your computer and use it in GitHub Desktop.
Code to utilize the newly-created wp_cron schedule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add the action or social posts deleting | |
add_action( 'social_delete_posts', function() { | |
$args = array( | |
'post_type' => 'social_posts', | |
'post_status' => 'any', | |
'posts_per_page' => -1, | |
'date_query' => array( | |
array( | |
'column' => 'post_date_gmt', | |
'before' => '1 month ago', | |
), | |
), | |
); | |
$posts = get_posts($args); | |
foreach( $posts as $post ) { | |
$force_delete = true; // bypass trash | |
wp_delete_post( $post->ID, $force_delete ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment