WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] CSS background question [SOLVED] (1 post)

  1. danielread89
    Member
    Posted 2 years ago #

    Let me first say, I am very new to PHP & WordPress but having knowledge in other languages I just jumped in. On the theme I am working on the background image is set in my CSS file like so:

    body{
    	background: #000000 url(images/main_background.png);
    	background-position: top center;
    	background-repeat: no-repeat;
    	color: #ffffff;}

    My question is how would i use a different background for "pages". I tried this and now the background will not show on any of my pages including the home page:

    <?php
    	if (is_page(702))
    		{
    		background: #000000 url(images/main_background.png);
    		}
    	else
    		{background: #000000 url(images/pageBG.png);}
    	?>

    Even if that code did work it would only change the background for that individual page with id 702. First what am I doing wrong with the code I did and how would I make it work for all pages except the home page?

    Thanks in advanced for any responses.

    EDIT::::
    Of course after finally asking the question on the forum I came up with the solution. Apparently you can not use the if/then statement in the CSS file. Instead I went to "page.php" and added a class to the body like so:

    <body id="page" class="second">
    I then edited my CSS file to look like this:

    body{
    
    		background: #000000 url(images/main_background.png);
    
    }
    
    .second {
    		background: #000000 url(images/pageBG.png);
    }

    and taa daa that worked.

Topic Closed

This topic has been closed to new replies.

About this Topic