Created
November 6, 2019 08:33
-
-
Save wickywills/dd83e4c782cfa6dddbfd63409c44d7a1 to your computer and use it in GitHub Desktop.
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
``` | |
/* | |
Plugin Name: Bulk Update Post | |
Description: Quick plugin to update posts with whatever you want | |
Author: James Wills | |
*/ | |
add_action('init','update_stuff'); | |
function update_stuff(){ | |
$my_posts = get_posts( array('post_type' => 'product' ) ); | |
foreach ( $my_posts as $my_post ): | |
if($my_post->post_title === 'test-en') { | |
$my_post->post_title = 'test-en-updated'; | |
} | |
wp_update_post( $my_post ); | |
endforeach; | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment