WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Alt background image on static pages? (7 posts)

  1. Max Sewell
    Member
    Posted 3 years ago #

    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

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

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

  3. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    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()

  4. Max Sewell
    Member
    Posted 3 years ago #

    Thanks people! Thank you, thank you --I'll give those ideas a try!

  5. Max Sewell
    Member
    Posted 3 years ago #

    http://www.emilyroche.com/

    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

  6. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    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

  7. Max Sewell
    Member
    Posted 3 years ago #

    Thanks alchymyth! --it works perfectly!

Topic Closed

This topic has been closed to new replies.

About this Topic