Last active
November 15, 2018 01:14
-
-
Save serguk89/d0957061d3b4735e2cca502e0aa809d1 to your computer and use it in GitHub Desktop.
automatically select parent terms
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
add_action('set_object_terms', 'auto_set_parent_terms', 9999, 6); // automatically select parent terms | |
function auto_set_parent_terms( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { | |
foreach( $tt_ids as $tt_id ) { | |
if ($parenttags = get_ancestors($tt_id, $taxonomy)) | |
{ | |
wp_set_object_terms( $object_id, $parenttags, $taxonomy, true ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment