Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('publish_POST-TYPE-SLUG', 'select_parent_terms', 10, 2); // automatically select parent terms
- function jr_select_parent_terms($post_id, $post) {
- if(!wp_is_post_revision($post_ID)) {
- $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 );
- }}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement