我只是很难弄清楚为什么我在\'quot;}上出错"E;“之后”$附件\\u image“;“前一行”"E;。我可能太累了,看不到它。
<?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>