diff --git a/extended-toc.php b/extended-toc.php index 57501c7..317cd71 100644 --- a/extended-toc.php +++ b/extended-toc.php @@ -455,6 +455,7 @@ if( !class_exists('ExToC') ) { $this->minLevel = $matches[0][2]; // lowest level e.g. h3 $currentLevel = $this->minLevel; // $minLevel; + $this->counter[$currentLevel] = 0; for( $i = 0; $i < count($matches); $i++ ) { /** get anchor and add to find and replace arrays **/ @@ -477,7 +478,7 @@ if( !class_exists('ExToC') ) { /** Check if header lower current header, then add level and update current header */ if( $matches[$i][2] > $currentLevel && $this->options['show_hierarchy'] == true) { $currentLevel = $matches[$i][2]; - $this->counter[$currentLevel] = 1; + $this->counter[$currentLevel] += 1; } else if( $matches[$i][2] < $currentLevel && $matches[$i][2] >= $this->minLevel && $this->options['show_hierarchy'] == true) { $currentLevel = $matches[$i][2];