0
<?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/

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.

  • Thanks for reply, But that's not working, please check SS: nimb.ws/TOqHQ6 – Karan Kcoresys Dec 18 '18 at 10:06
  • I didn't check your CSS. the image itself is pulling in fine with that. I've edited the answer to fix CSS. – mrben522 Dec 18 '18 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.