如果您想添加背景图像,可以在html中使用内联css
PHP:
<?php
if(has_post_thumbnail())
{
$desktop_src = wp_get_attachment_image_src(get_post_thumbnail_id(), \'desktop\');
$ipad_src = wp_get_attachment_image_src(get_post_thumbnail_id(), \'ipad\');
$mobile_src = wp_get_attachment_image_src(get_post_thumbnail_id(), \'mobile\');
$desktop = \'style="background: url(\'.$desktop_src[0].\');"\';
$ipad = \'style="background: url(\'.$ipad_src[0].\');"\';
$mobile = \'style="background: url(\'.$mobile_src[0].\');"\';
}
?>
HTML:
<div id="desktop" <?php echo $desktop; ?>></div>
<div id="ipad" <?php echo $ipad; ?>></div>
<div id="mobile" <?php echo $mobile; ?>></div>