function jr_select_parent_terms($post_id, $post) { if( $post->post_type == 'revision' ) return; $taxonomies = get_taxonomies(array('_builtin' => false)); foreach ($taxonomies as $taxonomy ) { $terms = wp_get_object_terms($post->ID, $taxonomy); foreach ($terms as $term) { $parenttags = get_ancestors($term->term_id,$taxonomy); wp_set_object_terms( $post->ID, $parenttags, $taxonomy, true ); } } }