【发布时间】:2020-10-14 21:51:54
【问题描述】:
我相当确定这个错误是由 PHP 更新引起的,类似于这篇文章 (Fatal error: 'break' not in the 'loop' or 'switch' context in),我只是不知道如何更正代码。
我收到此错误:
致命错误:“继续”不在第 32 行 [模板名称] 中的“循环”或“切换”上下文中
这是第 32 行的代码:
<h2><a href="<?php if(is_wp_error( $term_link )) {continue;} else {echo esc_url( $term_link );} ?>"><?php echo $term_name; ?></a></h2>
我该如何解决?
【问题讨论】:
-
为什么你需要一个不属于循环的
continue?这在哪种情况下有意义? -
删除
continue;。 -
continue 和 break 语句是循环的一部分。在这里,您没有使用任何循环。请确保您使用的是循环(for、while)。
-
我删除了整行代码。现在一切似乎都运行良好。感谢您的建议!