Skip to content

Instantly share code, notes, and snippets.

@graylaurenm
Created September 27, 2017 20:43
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 graylaurenm/712d08d1efed9c30df96802476a219ae to your computer and use it in GitHub Desktop.
Save graylaurenm/712d08d1efed9c30df96802476a219ae to your computer and use it in GitHub Desktop.
Force posts to update (make no changes)
<?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