Skip to content

Instantly share code, notes, and snippets.

@hatsumatsu
Created July 18, 2018 14:08
Show Gist options
  • Save hatsumatsu/2a583b2a9869cc021ed3cc05f52b2422 to your computer and use it in GitHub Desktop.
Save hatsumatsu/2a583b2a9869cc021ed3cc05f52b2422 to your computer and use it in GitHub Desktop.
Hi Lukas!
<?php
/**
* Temporary function:
* @return [type] [description]
*/
function convert_to_legacy_posts() {
if( !is_admin() ) {
return;
}
if( $_REQUEST['convert_to_legacy_posts'] && current_user_can( 'manage_options' ) ) {
print_r( 'start converting...' );
$posts = get_posts(
array(
'post_type' => 'XXX',
'posts_per_page' => -1
)
);
if( $posts ) {
foreach( $posts as $post ) {
update_post_meta( $post->ID, 'XXX', '1' );
}
}
}
}
add_action( 'admin_init', 'convert_to_legacy_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment