Skip to content

Instantly share code, notes, and snippets.

@hinnerk-a
Created October 4, 2012 18:12
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Using wp_update_term properly for setting parent terms in hierarchical taxonomies
<?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 ) );
?>
@luisfdeandrade
Copy link

Nice gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment