Skip to content

Instantly share code, notes, and snippets.

@crimson-med
Created December 8, 2017 10:01
Show Gist options
  • Save crimson-med/910220161e9c00e37585bdd7aeedc56b to your computer and use it in GitHub Desktop.
Save crimson-med/910220161e9c00e37585bdd7aeedc56b to your computer and use it in GitHub Desktop.
Updating wordpress parent ID with proper linking in term_taxonomy using wp_update_term
<?php
//localID is the termID you want to change
//parentLocalID is the parent term ID you want to put
function updateParentID($localID, $parentLocalID){
global $wpdb;
$table_name = $wpdb->prefix.'term_taxonomy';
$value = wp_update_term( $localID, 'product_cat', array( 'parent' => $parentLocalID ) );
if ( is_wp_error( $value ) ) {
return $value->get_error_message();;
}else {
return true;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment