Advertisement
Guest User

Untitled

a guest
May 25th, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. add_action('publish_POST-TYPE-SLUG', 'select_parent_terms', 10, 2); // automatically select parent terms
  2. function jr_select_parent_terms($post_id, $post) {
  3. if(!wp_is_post_revision($post_ID)) {
  4. $taxonomies = get_taxonomies(array('_builtin' => false));
  5. foreach ($taxonomies as $taxonomy ) {
  6. $terms = wp_get_object_terms($post->ID, $taxonomy);
  7. foreach ($terms as $term) {
  8. $parenttags = get_ancestors($term->term_id,$taxonomy);
  9. wp_set_object_terms( $post->ID, $parenttags, $taxonomy, true );
  10. }}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement