• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Custom backgrounds for pages

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Custom backgrounds for pages

This topic is: not resolved

Tagged: custom backgrounds, page backgrounds

  • This topic has 6 replies, 2 voices, and was last updated 9 years, 12 months ago by Elaine Griffin.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • March 27, 2013 at 11:39 am #31556
    Elaine Griffin
    Member

    Hello,

    I would like to add custom backgrounds to some pages of a site I'm working on. I've never done this, but I think you can add it with some code like this:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <?php if (is_page('page1') ):
    // page 1 ?>
    <style type="text/css">
    body {background-color:#000;background-image:url(/images/background.jpg);background-repeat:repeat;}
    </style>

    <?php elseif (is_page('page2') ):
    // page 2?>
    <style type="text/css">
    body {background-color:#000;background-image:url(/images/background2.jpg);background-repeat:repeat;}
    </style>

    <?php endif; // end the if, no images for other other categories ?>

    Does this go in page.php or the functions file? Either way when I tried to insert it I kept getting syntax errors.
    I'm still learning php, obviously! :)!

    March 27, 2013 at 12:02 pm #31565
    Brad Dalton
    Participant

    PHP generally goes in the child themes functions.php file but not with opening and closing php tags.

    These are only needed when pasting PHP code into any of the Genesis hook fields when using the Genesis Simple Hooks plugin.

    This is the reason you are getting the errors.

    Where did you get this code from?


    Tutorials for StudioPress Themes.

    March 27, 2013 at 12:08 pm #31568
    Elaine Griffin
    Member

    Thank you Brad!

    Okay, that's what I thought, but I couldn't seem to get rid of the errors. Will try again.

    This was from the WP support forum.

    March 27, 2013 at 12:21 pm #31574
    Brad Dalton
    Participant

    Easier to use CSS code and grab the post/page i.d from the source code for each or create a custom body class.


    Tutorials for StudioPress Themes.

    March 27, 2013 at 12:23 pm #31575
    Elaine Griffin
    Member

    I think I saw that too. Something along the lines of:

    .custom-page .id-4

    For example. I can't quite remember. It's been one of those days!

    March 27, 2013 at 1:19 pm #31587
    Brad Dalton
    Participant

    Grab the body class from your source code which includes the page or post i.d and use it as the selector with the declarations you need.

    Example: body class="single single-post postid-37615

    So you'd use . postid-37615 { your CSS declarations }

    Further reading: http://www.w3schools.com/css/css_background.asp

    Or install a plugin http://wordpress.org/extend/plugins/background-per-page/screenshots/


    Tutorials for StudioPress Themes.

    March 27, 2013 at 1:22 pm #31588
    Elaine Griffin
    Member

    Oh, I know how to do that! It's similar to using images in the nav bar. I need to start thinking of these as transferable to other applications. Thanks again Brad!

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble