Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当自定义字段“imageembed”没有值时,如何调整此代码以不显示图像?
<?php $imageid = get_post_meta($post->ID, 'imageembed', true); ?> <div class="newsimage"><img src="<?php echo wp_get_attachment_url( $imageid ); ?>" width="640" /></div>
像这样的东西
<?php if (strlen($imageid = get_post_meta($post->ID, 'imageembed', true))) { ?> <div class="newsimage"><img src="<?php echo wp_get_attachment_url((int) $imageid); ?>" width="640" /></div> <?php } ?>