Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Wordpress Page Background Image

Wordpress Page Background Image

Wordpress Page Background Image

I'm trying to get a background image to appear on one page only. I found the following code online that people say have worked (I'm using long form page names)


<?php if (is_page('down-the-rabbit-hole-to-wonderland') ): // page 1 ?>
<style type="text/css">
body {
background-image:url(<?php bloginfo('template_url'); ?>/images/body-bg.jpg);background-repeat:repeat;

When I implement it though, I get a parsing error...

Parse error: syntax error, unexpected $end in /home/krypticv/public_html/test/wp-content/themes/InteriorDesigns/page.php on line 59

The following is the code for the page.php file. Any help is appreciated


<?php get_header(); ?>

<div class="outer" id="contentwrap">


	<div class="postcont">

		<div id="content">	

			<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

			<div class="post" id="post-<?php the_ID(); ?>">

			<h2 class="title"><?php the_title(); ?></h2>

				<div class="entry">

<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(300,225), array

("class" => "alignleft post_thumbnail")); } ?>

					<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); 



					<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => 

'</p>', 'next_or_number' => 'number')); ?>




			<?php endwhile; endif; ?>

		<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>




<?php get_sidebars('right'); ?>


<?php get_footer(); ?> 


RE: Wordpress Page Background Image

I think this would be much easier to make a specific template for this one file and give the body tag a class. then just create that class in your stylesheet.

the one caveat of course would be that you would have to include your header info on the page itself and not use an include as your body tag is in your header which is universal.

Also where are you using this snippet of code and it doesn't look like you are closing or opening your php statement.


<?php if (is_page('down-the-rabbit-hole-to-wonderland') ): // page 1 { ?>
<style type="text/css">
body {
background-image:url(<?php bloginfo('template_url'); ?>/images/body-bg.jpg);background-repeat:repeat;

<?php } ?> 

I'm no php coder but you need to open and close your statement.

Darryn Cooke
www.darryncooke.com | Marketing and Creative Services

RE: Wordpress Page Background Image


<?php if (is_page('down-the-rabbit-hole-to-wonderland') ): // page 1 ?> 

A semicolon should be used here instead of a colon.

The semicolon tells PHP to stop after that line. Without it, PHP is getting confused by your unending conditional statement.

RE: Wordpress Page Background Image

nope. it should be a colon.

after the </style> closing tag insert this


<?php endif; ?> 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close