Skip to content

Instantly share code, notes, and snippets.

@sabrina-zeidan
Created August 20, 2017 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sabrina-zeidan/f4f2d9d2fc56c8ef7d00058dca27af26 to your computer and use it in GitHub Desktop.
Save sabrina-zeidan/f4f2d9d2fc56c8ef7d00058dca27af26 to your computer and use it in GitHub Desktop.
Publishing function for WP MU Cron [Wordpress]
if (!defined('ABSPATH')) {require_once(dirname( __FILE__ ) . '/wp-load.php');}
global $wpdb;
$blog_id = get_current_blog_id();
$args = array('post_type' => 'post', 'post_status' => 'draft' , 'numberposts' => 50, 'fields' => 'ids');
$future_posts = get_posts( $args );
foreach ($future_posts as $future_post) {
$my_post = array('ID' => $future_post, 'post_status' => 'publish');
$upd = wp_update_post( $my_post, true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment