Support » Themes and Templates » if-else background switch

  • I am trying to modify the following piece of code in header.php:
    <?php /* Checks to see whether it needs a sidebar or not */ if ((! $withcomments) && (! is_single()) && (! is_page())) { ?>
    #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; } <?php } else { // No sidebar ?>
    #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } <?php } ?>

    Here’s what I want:
    I want to use kubrickbg.jpg for all pages EXCEPT for pages rendered with page.php. That is, all pages except those I create through the admin panel (that aren’t the links or archives template). I’m not to sure what the requiste conditions in the if statement above are for accomplishing this. Here’s the particular problem: I have a 3-column look, the colors of which are established by the background image, except that when one clicks the permalink of a post in order to view comments, it switches to kubrickbgwide.jpg. I don’t want this. Any help?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Are you talking about Page as in individual Pages created with the Pages Panel and not the Write Posts panel? The ones “out” of the WordPress Loop, so to speak?

    These: Creating individual Pages

    You can put any style you want onto those, totally different from the rest of your post pages. And if you don’t want kubrickbgwide.jpg, change the graphic to something you do want or get rid of it.

    Are you asking how to get rid of the graphic? Delete it from the theme folder. Or replace it with your own. Does that help?

    Okay, go to, notice the line the outlines each column, now click on any particualar post, and notice that one of the lines dissapears, cause it’s calling kubrickbgwide.jpg. Now, on the nave bar at the top left, click on “about,” and you’ll see that it, too, is using kubrickbgwide.jpg. I created the about page through the pages panel, as you say, which uses page.php to render the material, no?

    Once my site comes back up….

    Do you want the kubrickbgwide.jpg on your site at all? That’s the main question. If not, get rid of it. Change the CSS that references it in the style.css in your wp-content/themes so it goes away when initiated. That’s it. Gone. If you only want it to show up on your posts and NOT your Pages, then you create a new style.css file, a copy of the original, and change the reference to the kubrickbgwide.jpg to make it go away and change the name of the style sheet in the header at the top of the style sheet so it will show up as something different in your Presentation Themes, then choose that stylesheet instead of your default theme style when in EDIT Page panel for about. That should fix it for you.

    And now that your site is up, I’m looking at it with Firefox and the line that is on the left and right of the main page is gone on the right because there are no ads in the right “sidebar”. Other than that, I see lines where lines look like they should be. Everything looks fine…OH, finally found it. My answer still holds. Get rid of the graphic reference.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘if-else background switch’ is closed to new replies.