Skip to content

Instantly share code, notes, and snippets.

@ScottPhillips
Created July 11, 2012 21:01
Show Gist options
  • Save ScottPhillips/3093469 to your computer and use it in GitHub Desktop.
Save ScottPhillips/3093469 to your computer and use it in GitHub Desktop.
Update Wordpress Post/Page Data...
<?php
function wpa47153_run_once(){
$posts = get_posts(array('numberposts' => -1) );
foreach($posts as $p) :
$meta = get_post_meta($p->ID, 'meta_key',true);
if($meta) :
$my_post = array();
$my_post['ID'] = $p->ID;
$my_post['post_content'] = $meta . "<br/>" . $p->post_content ;
// Update the post into the database
wp_update_post( $my_post );
unset($my_post);
//remove the meta key
delete_post_meta($p->ID, 'meta_key');
endif;
endforeach;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment