I'm just having trouble figuring out why I'm getting an error at the "}" after the "$attachment_image" line, just before "". I'm probably just too tired to see it.
<?php if($term) {
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'mediacat',
'terms' => $term->term_id,
)
),
'orderby' => 'rand',
'post_status' => 'inherit',
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) :
$loop->the_post();
$item = get_the_id();
$attachment_image = wp_get_attachment_image_url( $item, 'square' );
} ?>
<figure class="cblNavMenu--icon__imgwrap">
<div class="navimage" style="background-image: url('<?php if($term) { echo $attachment_image; } if($menu_link){ the_permalink(); } ?>');"></div>
</figure>
<?php if($term) {
endwhile;
wp_reset_postdata();
} ?>
</div>
<span class="cblNavMenu--label"><?php if($term) { if($cat_label) { echo $cat_label; } else { echo $current_term_name; } } if($menu_link){ if($cat_label) { echo $cat_label; } else { the_title(); } } ?></span>
endwhile
.if() {}
before you close thewhile() : endwhile;
, which is where the error is coming from.