Skip to content

Commit 62eee44

Browse files
committed
Fix TOC nesting: initialize stack properly when first heading isn't h2
1 parent 058d1cf commit 62eee44

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎includes/frontend/class-toc.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ private static function build_toc_html( array $headings, array $args ): string {
186186
}
187187
if ( ! empty( $stack ) && end( $stack ) === $level ) {
188188
$output .= '</li>';
189-
} else {
189+
} elseif ( ! empty( $stack ) ) {
190190
$output .= '<ul>';
191191
$stack[] = $level;
192+
} else {
193+
$stack[] = $level;
192194
}
193195
}
194196

0 commit comments

Comments
 (0)