Skip to content

Instantly share code, notes, and snippets.

@agkovalev
Last active March 31, 2021 13:37
Show Gist options
  • Save agkovalev/874e2b97735b1ef9c841d8b1dc908ca7 to your computer and use it in GitHub Desktop.
Save agkovalev/874e2b97735b1ef9c841d8b1dc908ca7 to your computer and use it in GitHub Desktop.
Wordpress: change posts author programmatically
<?php
// don't forget to delete it or comment it out after using!
add_action( 'init', function(){
$pids = [ 3439, 3214, 5370 ]; // change it
$new_athor = 3; // change it
foreach ( $pids as $pid ) {
wp_update_post( [
'ID' => $pid,
'post_author' => $new_athor
] );
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment