Skip to content

Commit

Permalink
Merge pull request #2687 from rebeccahum/fix/get_term_tree_nonexisten…
Browse files Browse the repository at this point in the history
…t_parent

get_term_tree(): fix infinite loop for non-existent parent
  • Loading branch information
felipeelia authored Mar 28, 2022
2 parents 3c5831c + 849a60f commit 46c8dfb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function get_term_tree( $all_terms, $orderby = 'count', $order = 'desc', $flat =
$terms_map[ $term->term_id ] = $term;
}

if ( empty( $term->parent ) ) {
if ( empty( $term->parent ) || ! term_exists( $term->parent, $term->taxonomy ) ) {
$term->level = 0;

if ( empty( $orderby ) ) {
Expand Down

0 comments on commit 46c8dfb

Please sign in to comment.