Skip to content

Instantly share code, notes, and snippets.

@ajgagnon
Created September 6, 2021 14:05
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 ajgagnon/06193ff9ecaf149cda5892cf2962099b to your computer and use it in GitHub Desktop.
Save ajgagnon/06193ff9ecaf149cda5892cf2962099b to your computer and use it in GitHub Desktop.
Migrate Threads to different item
<?php
add_action('admin_init', function() {
if ( 27 !== get_current_user_id()) {
return;
}
$threads = get_posts([
'numberposts' => -1,
'post_type' => 'phw_comment_loc',
'meta_key' => 'parent_id',
'meta_value' => 20903
]);
foreach($threads as $thread) {
update_post_meta($thread->ID, 'parent_id', 20901);
update_post_meta($thread->ID, 'item_id', 20901);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment