WordPress.org

Support

Support » Themes and Templates » [Resolved] Alt background image on static pages?

[Resolved] Alt background image on static pages?

  • I’m trying to figure out how to use an alternate background image on static pages. I know css and have a passive knowledge of php. Any help would be appreciated.

    I did do a search for this but came up empty.

    Thanks,

    Max

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi

    @esmi

    Forum Moderator

    Are you using the body_class function in your theme’s header.php

    background image for what?

    general, you could embed the style definition into haeder.php with a conditional tag is_page() or is_page('pagename')

    something like:

    <?php if(is_page()) { ?>
    <style type="text/css" media="screen">
    #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/staticpagebg.jpg") repeat-y top; }
    </style>
    <?php } ?>

    http://codex.wordpress.org/Conditional_Tags

    @esmi:
    thanks, of course, i keep forgetting body_class()

    Thanks people! Thank you, thank you –I’ll give those ideas a try!

    words that fit

    Hi,

    I was able to create an alternate background for my client’s home page using this php:

    <?php if($_GET[“page_id”] != 0 && $_GET[“page_id”] != 2 && $_GET[“page_id”] != 33){echo “<div id=\”wrap-out\”><div id=\”wrap\”>”;} else {echo “<div id=\”wrap-out-alt\”><div id=\”wrap\” style=\”min-height: 1081px;\”>”;} ?>

    Trouble is, my client also didn’t want the blog excerpts on her home page, so I created a special “blogs” page (http://www.emilyroche.com/?page_id=77). Now when you’re on that page and you click on MORE under an excerpt, you get a new page (http://www.emilyroche.com/?p=59) with the alternate background (which is bad).

    I’m guessing its because the software wants the blog displayed on the home page but I’ve circumvented that.

    Any way around this?

    Thanks,

    Max

    try and integrate a || is_single() into your code:

    <?php if($_GET["page_id"] != 0 && $_GET["page_id"] != 2 && $_GET["page_id"] != 33 || is_single() ){echo "<div id=\"wrap-out\"><div id=\"wrap\">";} else {echo "<div id=\"wrap-out-alt\"><div id=\"wrap\" style=\"min-height: 1081px;\">";} ?>

    http://codex.wordpress.org/Conditional_Tags

    Thanks alchymyth! –it works perfectly!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Alt background image on static pages?’ is closed to new replies.
Skip to toolbar