Created
October 4, 2012 18:12
-
-
Save hinnerk-a/3835366 to your computer and use it in GitHub Desktop.
Using wp_update_term properly for setting parent terms in hierarchical taxonomies
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 | |
// set terms | |
wp_set_object_terms( $post_id, $object_types, 'immomakler_object_type', true ); | |
// make terms hierarchial by objektart | |
$term_parent = get_term_by( 'slug', $openimmo_data['objektart'], 'immomakler_object_type' ); | |
$term_child = get_term_by( 'slug', $openimmo_data['objektart_detail'], 'immomakler_object_type' ); | |
delete_option( 'immomakler_object_type_children' ); // workaround for WordPress not updating this option properly | |
wp_update_term( $term_child->term_id, 'immomakler_object_type', array( 'parent' => $term_parent->term_id ) ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice gist