0

I have the following markup.I am not able to make it work.It shows syntax error.

if(has_terms( array('something','else'), 'product_cat' ) ) {
   $output .= '<div class="list_image">';
   $output .= '</div>';
}else{
  $output .= '<div class="list_post">';
  $output .= '</div>';
}
endif;

What syntax error I made?

1 Answer 1

3

Remove endif; When you use curly braces you don't need (and cannot use) endif.

This:

if (true) {
  echo 'hello';
} else {
  echo 'goodbye';
}

...is equivalent to this:

if (true):
  echo 'hello';
else:
  echo 'goodbye';
endif;

You cannot mix the two styles.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.