republish-posts.php
/**
 * Here is the actual function to republish the posts
 * @wp-hook	rpUpdatePostsHourlyEvent
 * @return	void
 */
Here is the actual function to republish the posts
@wp-hook     rpUpdatePostsHourlyEvent
@return      void
Here is the actual function to republish the posts @wp - hook rpUpdatePostsHourlyEvent @return void
function rpUpdatePostsHourly()
{
    $args = array(
	'posts_per_page'   => -1,
	'meta_key'         => 'rpRepublishDate',
	'post_type'        => 'post',
	'post_status'      => 'publish',
	'suppress_filters' => false
    );
    $posts_array = get_posts( $args );
    foreach ($posts_array as $post) {
        $newDate = get_post_meta($post->ID, 'rpRepublishDate', true);
        if ((int)$newDate < time()) {
            $my_post = array(
                'ID' => $post->ID,
                'post_date' => date('Y-m-d H:i:s'),
                'post_status' => 'draft'
            );
            wp_update_post( $my_post );
            delete_post_meta($post->ID, 'rpRepublishDate');
            $my_post['post_status'] = 'publish';
            wp_update_post( $my_post );
        }
    }
}
function rpUpdatePostsHourly ( ) { $ args = array ( 'posts_per_page' => - 1 , 'meta_key' => 'rpRepublishDate' , 'post_type' => 'post' , 'post_status' => 'publish' , 'suppress_filters' => false ) ; $ posts_array = get_posts ( $ args ) ; foreach ( $ posts_array as $ post ) { $ newDate = get_post_meta ( $ post -> ID , 'rpRepublishDate' , true ) ; if ( ( int ) $ newDate < time ( ) ) { $ my_post = array ( 'ID' => $ post -> ID , 'post_date' => date ( 'Y-m-d H:i:s' ) , 'post_status' => 'draft' ) ; wp_update_post ( $ my_post ) ; delete_post_meta ( $ post -> ID , 'rpRepublishDate' ) ; $ my_post [ 'post_status' ] = 'publish' ; wp_update_post ( $ my_post ) ; } } }
Here is the actual function to republish the posts
 @wp-hook     rpUpdatePostsHourlyEvent
 @return      void
Here is the actual function to republish the posts @wp - hook rpUpdatePostsHourlyEvent @return void
#var_dump($post);