It appears that you have some mixed syntax.
The endwhile;
does not need a closing curly brace. I think that the curly brace you have there is closing the else
that comes later, but because you close and reopen PHP to put in the </ul>
tag, it causes a syntax error.
Try it like this (note where the curly brace was moved from the endwhile line to the else line):
<div class="product-loop-wrapper">
<?php
$terms = get_the_terms($post->ID, 'product-lines', 'string');
$term_ids = wp_list_pluck($terms, 'term_id');
foreach ($terms as $term) {
$args = array(
'post_type' => 'product',
'orderby' => 'date',
'order' => 'DESC',
'ignore_sticky_posts' => 1,
'post_status' => 'publish',
'posts_per_page' => -1,
'post__not_in' => array( $post->ID ),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product-lines',
'field' => 'id',
'terms' => $term_ids
),
array(
'taxonomy' => 'product-types',
'field' => 'slug',
'terms' => 'moldings'
)
)
);
$product_tiles_loop = new WP_Query($args);
if ($product_tiles_loop->have_posts()) { ?>
<ul class="products columns-4">
<?php while ($product_tiles_loop->have_posts()) : $product_tiles_loop->the_post(); ?>
<li <?php post_class(); ?>>
<div class="product-h">
<a class="woocommerce-LoopProduct-link woocommerce-loop-product__link" href="https://wordpress.stackexchange.com/questions/320764/<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
<div class="post-meta">
<h2 class="woocommerce-loop-product__title"><?php the_title(); ?></h2>
</div>
</a>
<a class="button product_type_simple" href="https://wordpress.stackexchange.com/questions/320764/<?php the_permalink(); ?>" rel="nofollow">View Product</a>
</div>
</li>
<?php endwhile; // END if have_posts loop ?>
</ul>
<?php
} else {
echo 'Sorry, there are no Moldings in this Product Line';
}
wp_reset_postdata();
}
?>
</div>