Support » Themes and Templates » featured image as site background

  • Hi guys,

    So I’m making a theme for a deejay and i want to display the featured img (the big version) as background when it’s set into the post/page

    I already activated the function in functions.php

    BUT! when there’s no featured image (in archive etc) selected, it has to take a random iamge out of a directory in the theme folder.

    <body <?php body_class(); ?>>
    <!-- SET BACKGROUND -->
    <div id="maximage">
    	<?php if ( has_post_thumbnail() ) {
    	the_post_thumbnail(); } else ?>
    	<img src="<?php echo get_template_directory_uri(); ?>/img/fp/sakso003.jpg" alt="" />
        <?php endif ?>
    </div> <!-- #maximage -->
    <div class="gridContainer clearfix" class="hfeed site">

    this is done in header.php so it’s outside the loop.

    thanks in advance!

    (the background is using the Maximage v2 Javascript/background-slider)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Andrew Nevins


    I could try help out with the CSS-side of it if you want, but you’ll need to provide a link to your webpage with the featured image already.

    the css and stuff is all done. it’s the php I need 😉

    the javacript turns the div with id=”maximage” into a background us lower z-index etc. So that’s all ok!

    inside the div i’ve put
    <img src="<?php echo get_template_directory_uri(); ?>/img/fp/sakso003.jpg" alt="" />
    for now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘featured image as site background’ is closed to new replies.