活动日历以图片为正文背景?

时间:2018-12-17 作者:Karan Kcoresys

<?php if (has_post_thumbnail( $post->ID ) ):
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), \'full\' ); 
elseif (tribe_event_featured_image( $event_id = get_the_ID())): $thumb = get_attachment_image_src(tribe_event_featured_image( $event_id), \'large\' ); 
else: $thumb = array(get_template_directory_uri().\'/images/background.jpg\'); endif;?> <body <?php body_class(); ?> style="background-image: url(\'<?php echo $thumb[\'0\'];?>\') no-repeat fixed">
各位专家您好,

请帮助,我正在使用“事件日历”插件,我想使用事件特征图像作为正文背景。请检查代码!演示活动页面:http://rankonone.com/dev/downtown/event/the-lion-king/

1 个回复
SO网友:mrben522

<?php 

$id = get_the_ID();
if (has_post_thumbnail( $id ) ):
    $thumb = get_the_post_thumbnail_url($id, \'full\'); 
elseif (tribe_event_featured_image( $id)): 
    $thumb = tribe_event_featured_image( $event_id, \'large\', false, false ); 
else: 
    $thumb = get_template_directory_uri().\'/images/background.jpg\'; endif;?>
<body <?php body_class(); ?> style="background-image: url(\'<?php echo $thumb;?>\'); background-size: cover;">
?>
而且你实际上不需要elseif 陈述tribe_event_featured_image 是包含一些附加包装html的后期缩略图图像的包装。

相关推荐