wordpress 致命错误:“continue”不在“loop”或“switch”上下文中

jfewjypa  于 4个月前  发布在  WordPress
关注(0)|答案(1)|浏览(83)

我相当确定这个错误是由PHP更新引起的,类似于这篇文章(Fatal error: 'break' not in the 'loop' or 'switch' context in),我只是不知道如何纠正代码。
我收到这个错误:
Fatal error:'continue' not in the 'loop' or 'switch' context in [template name] on line 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>

字符串
我该怎么补救?

uinbv5nw

uinbv5nw1#

你把事情弄得太复杂了。把条件反过来:

<h2><a href="<?php if (!is_wp_error( $term_link )) { echo esc_url( $term_link ); }  ?>"><?php echo $term_name; ?></a></h2>

字符串

相关问题