Created
September 27, 2017 20:43
-
-
Save graylaurenm/712d08d1efed9c30df96802476a219ae to your computer and use it in GitHub Desktop.
Force posts to update (make no changes)
This file contains hidden or 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
<?php // Do not include this line | |
add_action( 'init', 'oc_force_post_update' ); | |
function oc_force_post_update() { | |
$my_posts = get_posts( | |
array( | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'posts_per_page' => 10, | |
'offset' => 0, | |
) | |
); | |
foreach ( $my_posts as $my_post ): | |
wp_update_post( $my_post ); // comment this out to test your query | |
// echo '<p>theoretically update ' . $my_post->ID . '</p>'; | |
endforeach; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment