admin管理员组文章数量:1122846
<?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">
Hello Sir Experts,
Please help, i am using "The Events Calendar" plugin, and i want to use event featured image as body backgound. Please check code! and it's demo event page: /
<?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">
Hello Sir Experts,
Please help, i am using "The Events Calendar" plugin, and i want to use event featured image as body backgound. Please check code! and it's demo event page: http://rankonone.com/dev/downtown/event/the-lion-king/
Share Improve this question asked Dec 17, 2018 at 12:17 Karan KcoresysKaran Kcoresys 135 bronze badges1 Answer
Reset to default 0<?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;">
?>
Also you don't actually need the elseif
statement, tribe_event_featured_image
is a wrapper for the post thumbnail image with some added wrapping html.
本文标签: plugin developmentThe Events Calendar featured image as body background
版权声明:本文标题:plugin development - The Events Calendar featured image as body background? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736281974a1926496.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论