• 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

Page Background Image

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 › Page Background Image

This topic is: not resolved

Tagged: background images

  • This topic has 15 replies, 3 voices, and was last updated 10 years ago by Jon Bellah.
Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • January 14, 2013 at 7:34 am #11803
    dynamic
    Participant

    Hello team

    How can I add a specific image to just a page. The site has a background image but I want a specific page to have a background image. Should I create a new template and if so how do I add the image into the code or is there a plugin that works with genesis and the Corporate theme

    http://www.coffeeculture.com.au

    Thanks

    January 14, 2013 at 7:39 am #11804
    Jon Bellah
    Member

    Add a custom body class to your functions.php file:

    add_filter( 'body_class', 'child_custom_body_class' );
    function child_custom_body_class( $classes ) {
     if ( is_page() )
     $classes[] = 'custom-body';
     return $classes;
    }
    

    Then you can target that in your css with:

    .custom-body {
    Your background image here
    }
    

    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

    January 14, 2013 at 7:40 am #11805
    dynamic
    Participant

    I have tried the following plugin's and they all fail

    Background per page
    Background slideshow
    Post Background
    Post Backgrounds
    WP Backgrounds Lite

    All fail

    January 14, 2013 at 7:46 am #11807
    dynamic
    Participant

    Thanks Jon, no joy

    http://www.coffeeculture.com.au/

    Parse error: syntax error, unexpected $end in /home/wwwcoffe/public_html/wp-content/themes/corporate/functions.php on line 69

    January 14, 2013 at 7:48 am #11809
    Jon Bellah
    Member

    Did you copy the [ php ] tag with it?


    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

    January 14, 2013 at 7:49 am #11810
    dynamic
    Participant

    Jon, now fixed code, still not pulling custom background image

    http://www.coffeeculture.com.au/wp-content/uploads/2013/01/home_back.png is the image

     

    Charles

    January 14, 2013 at 7:51 am #11811
    Jon Bellah
    Member

    In the code, where it says if (is_page()) you have to insert the slug of the page you want to add the class to. For example, if ( is_page('about-us')).


    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

    January 14, 2013 at 7:57 am #11812
    dynamic
    Participant

    No joy Jon

    if ( is_page('welcome'))

    was added into functions

    .custom-body {
    Your background image here
    }
    was added to style.css of corporate theme style sheet,

    Charles

    January 14, 2013 at 8:28 am #11820
    Jon Bellah
    Member

    Where it says "your background image here" you need to input the URL to your background image... in this case:

    .custom-body {
    background:url(/wp-content/uploads/2013/01/home_back.png);
    }
    

    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

    January 14, 2013 at 8:35 am #11824
    dynamic
    Participant

    Jon

    Line 739 of stylesheet says

    .custom-body {
    background:url(/wp-content/uploads/2013/01/home_back.png);
    }

    This code is in the style.css in the corporate theme folder

    Hmm, not sure what is going on

    January 14, 2013 at 8:56 am #11828
    dynamic
    Participant

    And this is what is in the functions page

    /**
    * Register a custom admin callback to display the custom header preview with the
    * same style as is shown on the front end.
    *
    */

    add_filter( 'body_class', 'child_custom_body_class' );
    function child_custom_body_class( $classes ) {
    if ( is_page('cafe'))
    $classes[] = 'custom-body';
    return $classes;
    }

    I've tried to make it trigger on the cafe page , still no joy

    It's just not pulling the background image

    Charles

    January 14, 2013 at 9:24 am #11836
    Bill Murray
    Member

    I think you're missing 2 curly braces...

    add_filter( ‘body_class’, ‘child_custom_body_class’ );
    function child_custom_body_class( $classes ) {
    if ( is_page(‘cafe’)) {
    $classes[] = ‘custom-body’;
    return $classes; 
    }
    }
    

    Web: https://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    January 14, 2013 at 9:27 am #11837
    Jon Bellah
    Member

    The code is actually working. Add !important to your custom body class, so it looks like:

    .custom-body {
    background:url(/wp-content/uploads/2013/01/home_back.png) !important;
    }
    

    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

    January 14, 2013 at 9:28 am #11838
    Jon Bellah
    Member

    Wish it would let me delete this... sorry double comment.


    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

    January 14, 2013 at 4:26 pm #11952
    dynamic
    Participant

    Jon,

    Thanks it now works and now I realise I was asking for it to be just behind the content, not as the page background.

    Thanks for your help so far

    Any suggestions as to how I can now limit it to the body of the page content?

    Charles

    January 14, 2013 at 6:00 pm #11966
    Jon Bellah
    Member

    Sure, use:

    .custom-body #inner {
    background:url(/wp-content/uploads/2013/01/home_back.png) !important;
    }
    

    Follow me on the Twitters at @JonBellah. I blog about web design, development and a lot about Genesis at CSSForge.com

  • Author
    Posts
Viewing 16 posts - 1 through 16 (of 16 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