Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

adding in background image on body of page

Posted on 2013-06-19
3
Medium Priority
?
534 Views
Last Modified: 2013-06-22
hi guys,

i want to add an image as background in the body of my wordpress site, how do i do that i am using theattached code  as a template

<?php
/*
Template Name: My Custom Indexer Page
*/

get_header(); ?>

	<div id="primary" class="site-content">
		<div id="content" role="main">

			<?php while ( have_posts() ) : the_post(); ?>
				<?php get_template_part( 'content', 'page' ); ?>
				<?php //comments_template( '', true ); ?>
			<?php endwhile; // end of the loop. ?>

		</div><!-- #content -->
	</div><!-- #primary -->
	<?php get_sidebar(); ?>

<div class="photos_videos">   
       <h2>PHOTOS &amp; VIDEOS</h2>
      <div id="banner-fade">
        <!-- start Basic Jquery Slider -->
        <ul class="bjqs">
       <?php  query_posts("cat=4"); 
         while (have_posts()) : the_post(); ?>
         <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
        <li><a href="<?php the_permalink(); ?>"><img src="<?php echo $image[0]; ?>" title="<?php the_title(); ?>"></a> </li>
         <?php endwhile;
	    wp_reset_query(); ?>
      
        </ul>
        <!-- end Basic jQuery Slider -->
      </div>  
     </div> <!-- #photos_videos -->  
    <div class="widget widget_foo_widget new1" id="foo_widget-2" >
    <h3>Latest News</h3>
   <?php query_posts("cat=3&showposts=3"); 
         while (have_posts()) : the_post();
		echo '<h2><a href="'.get_permalink().'">'.get_the_title().'</a><span>'.get_the_date('d-M-Y').'</span></h2>';
		echo '<p>'.substr(get_the_excerpt(),0,100).'...</p>';
		endwhile;
		wp_reset_query(); ?>
    </div>
	<div class="box_row4">
            	
                   <!--<a href="#"><img src="<?php //bloginfo('template_url') ?>/images/oxygen_map.png"></a>
            
                
                     <a href="#"><img src="<?php //bloginfo('template_url') ?>/images/wexford_img.png"></a>
                
          	      <a href="#"><img src="<?php //bloginfo('template_url') ?>/images/booking_forms.png" style="margin-right:0px;"></a>-->
                  
                  <a href="http://www.piratescove.ie/competitions-2/"><div class="red1">Competitions</div></a>
                  <a href="http://www.courtownharbour.com" title="Courtown Harbour Website"><div class="green1">Courtown Harbour</div></a>
                  <a href="http://www.piratescove.ie/hire-us/"><div class="blue1" style="margin-right:0px;">Hire Us</div></a>
                  
                  
             
            </div>
   </div><!-- #content -->
      
        
	</div><!-- #primary -->


     
	 


<?php get_sidebar(); ?>
<?php get_footer(); ?>

Open in new window


thanks
0
Comment
Question by:jonathanduane2010
3 Comments
 
LVL 36

Assisted Solution

by:SidFishes
SidFishes earned 528 total points
ID: 39259920
I'm not a php or wordpress guy but you generally need to define the body in css which I don't think you can do on that template as it looks like it's an include inside the body tag

In your main template (or associated style sheet) you'd add something like (depends on how you want your background to look)

body {
      width:100%;
      margin:auto;
      background: url('images/bg-body.jpg') no-repeat center center fixed;
      -moz-background-size: cover;
      -webkit-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
}
0
 
LVL 30

Assisted Solution

by:LZ1
LZ1 earned 524 total points
ID: 39259934
If your only looking to do it on that particular page or page-template, then you would use the WordPress body classes.


body.my-template-php{
width:100%;
      margin:auto;
      background: url('images/bg-body.jpg') no-repeat center center fixed;
      -moz-background-size: cover;
      -webkit-background-size: cover;
      -o-background-size: cover;
      background-size: cover;

Open in new window

0
 
LVL 44

Accepted Solution

by:
Chris Stanyon earned 528 total points
ID: 39261906
Just style the body normally by adding something like the following to your styles.css file:

body { background: url(someBackgroundImage.jpg) repeat left top #ffffff; }

Make sure the image is in your template folder...
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question