0

I am fairly sure that this error is caused by a PHP update, similar to this post (Fatal error: 'break' not in the 'loop' or 'switch' context in), I just don't know how to correct the code.

I'm getting this error:

Fatal error: 'continue' not in the 'loop' or 'switch' context in [template name] on line 32

Here is the code on line 32:

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

How do I fix it?

1 Answers1

0

You making this too complicated. Just invert the condition:

<h2><a href="<?php if (!is_wp_error( $term_link )) { echo esc_url( $term_link ); }  ?>"><?php echo $term_name; ?></a></h2>
EricSchaefer
  • 25,272
  • 21
  • 67
  • 103