• 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

Background image ONLY Homepage

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 › Background image ONLY Homepage

This topic is: resolved

Tagged: agency pro

  • This topic has 12 replies, 4 voices, and was last updated 11 years, 5 months ago by Bader.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • December 21, 2013 at 6:48 am #80590
    macrunner
    Participant

    Hi,

    I'm using Agency Pro.

    I would like to display an image only on the Homepage. A color, for example #fcfcfc, for everything else, Pages, Posts, Comments, etc..

    Thank you very much

    December 21, 2013 at 7:08 am #80591
    Brad Dalton
    Participant

    Try this http://wpsites.net/web-design/display-agency-pro-background-image-only-on-front-page/


    Tutorials for StudioPress Themes.

    December 21, 2013 at 7:20 am #80592
    Brad Dalton
    Participant

    You could also change the PHP in the functions file so its includes a conditional tag for the front page like this:

    if ( ! is_front_page() || ! get_background_image() )
    		return;
    

    Tutorials for StudioPress Themes.

    December 21, 2013 at 7:34 am #80596
    macrunner
    Participant

    Hi Brad,

    If I insert this code in the file front-page.php I get a blank page :

    //* Enqueue Backstretch script and prepare images for loading
    add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' );
    function agency_enqueue_backstretch_scripts() {
    
    	//* Load scripts only if custom background is being used
    	if ( ! get_background_image() )
    		return;
    
    	wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
    	wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' );
    
    	wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) );
    
    }

    This site DEMO: http://egotheme.it/

    December 21, 2013 at 7:58 am #80600
    macrunner
    Participant

    I tried the second method, I inserted this code in the front-page.php file but it has no effect:

    if ( ! is_front_page() || ! get_background_image() )
            return;

    With this code, blank page:

    //* Enqueue Backstretch script and prepare images for loading
    add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' );
    function agency_enqueue_backstretch_scripts() {
    
    	//* Load scripts only if custom background is being used
    	if ( ! get_background_image() )
    		return;
    
    	wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
    	wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' );
    
    	wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) );
    
    }

    Maybe I'm wrong something?

    December 21, 2013 at 8:37 am #80609
    Brad Dalton
    Participant

    Hi

    Please copy ALL the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++

    https://gist.github.com/braddalton/e503631f6937fce74f2c


    Tutorials for StudioPress Themes.

    December 21, 2013 at 8:55 am #80611
    macrunner
    Participant

    I used this code (github), no formatting, just as below:

    //* Enqueue Backstretch script and prepare images for loading
    add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' );
    function agency_enqueue_backstretch_scripts() {
    
    	
    	if ( ! is_front_page() || ! get_background_image() )
    		return;
    
    	wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
    	wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' );
    
    	wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) );
    
    }

    This code I added to functions.php of the child theme Agency Pro, but still blank page.
    I tried a new installation on the local server, same problem.

    December 21, 2013 at 9:08 am #80612
    macrunner
    Participant

    This is the functions.php file that I edited (download ZIP file): http://egotheme.it/functions.zip

    December 21, 2013 at 8:49 pm #80692
    Brad Dalton
    Participant

    You will need to remove the original code.


    Tutorials for StudioPress Themes.

    December 22, 2013 at 2:13 am #80733
    macrunner
    Participant

    Hi Brad,
    I'm sorry, I misunderstood.
    Ok now it works, thank you very much

    December 28, 2013 at 11:57 pm #81770
    omerkhan
    Member

    Thank you Brad!!

    December 29, 2013 at 6:28 am #81793
    Brad Dalton
    Participant

    No worries.


    Tutorials for StudioPress Themes.

    January 1, 2014 at 4:12 pm #82545
    Bader
    Member

    Thanks for the hint! 😉


    “Whether you think you can, or you think you can’t–you’re right.”
    ?• Henry Ford

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

© 2025 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