Created
December 8, 2017 10:01
-
-
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
This file contains 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
<?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