我正在使用 wp_get_attachment_image 为企业列表中的企业引入徽标。如果没有徽标,我想显示默认图像。
我知道这不起作用,并尝试了几种变体:
<?php $businessLogo = wp_get_attachment_image($business['logo']);?>
<?php if(empty ($businessLogo)) { ?>
<img src="<?php echo esc_url( home_url( '/' ) ); ?>wp-content/themes/child-theme/images/no_image.png" alt="<?php echo $business['name']; ?>" />
<?php } else { echo wp_get_attachment_image($business['logo']) } ?>
我会很感激任何建议