• 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

How to implement Backstretch (as pg bg) with child theme

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 › How to implement Backstretch (as pg bg) with child theme

This topic is: not resolved

Tagged: backstretch

  • This topic has 5 replies, 4 voices, and was last updated 12 years, 6 months ago by scoe.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • January 2, 2013 at 1:19 pm #8996
    Riavon
    Member

    These are the instructions I've saved for myself. Thought I'd share them with the community in case anyone else wants to use Backstretch for a full width responsive page background image. I'm still learning, but this is what I've figured out, so far.
    ---
    To use the backstretch script with Genesis sites, it's simple! Just add these lines of code:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.3/jquery.backstretch.min.js "></script>
    <script>
      // To attach Backstretch as the body's background
      $.backstretch("path-to-the-image/image.jpg");
    </script>

    ...in the Genesis Theme Settings area, in the very last entry field: "Enter scripts or code you would like output to wp_footer():" this code is for a single bg image sitewide. The script is called from where it is stored so there is no need to install the scripts locally (unless you want to.) If you do, those scripts can be found HERE.

    Or download the master files (all of it) from Scott Robbin
    ---
    To add Backstretch to a block level element:

    <script>
     $(".foo").backstretch("path/to/image.jpg");
    </script>

    After you create the page, get the page's id number by hovering mouse over the page name in the list view, looking at address bar at the bottom of your screen to show the page (post) id. Or view source of the page and look for it in the tag.

    For example:

    $(".page-id-635").backstretch("path-to-image.jpg");

    gives me a different background image on page id#635 than on the home/other pages.


    Twitter: @riavonentprises

    January 2, 2013 at 1:31 pm #9004
    Riavon
    Member

    All together it looks something like this (replace page id#'s and paths to images with your own). I upload the images to the media library and use the full path to it, i.e. "http://mywebsite.com/wp-content/uploads/2013/01/image-name-1.jpg " .

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.3/jquery.backstretch.min.js "></script>
    <script>
      // To attach Backstretch as the body's background
      $.backstretch("path-to-the/image1.jpg");
    </script>
    <script>
     $(".page-id-635").backstretch("path-to-the/image2.jpg");
     $(".page-id-725").backstretch("path-to-the/image3.jpg");
    </script>
    

    Twitter: @riavonentprises

    January 13, 2013 at 3:04 am #11551
    Ipstenu
    Member

    Since jquery is included in WP and reincluding it multiple times can cause things to go blaaaaargh, I would suggest this:

    Put the backstretch file in your theme's js folder and then this in your functions:


    /** Stretch your back **/

    function backstretch_js() {
    wp_enqueue_script(
    'backstretch',
    get_stylesheet_directory_uri() . '/js/backstretch.js',
    array('jquery'), '2.3', yes
    );
    }
    add_action('wp_enqueue_scripts', 'backstretch_js');

    (You can use //cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.3/jquery.backstretch.min.js instead of the get stylesheet if you just wanna use google).

    Then you just need the block element. I put it in /wp-admin/admin.php?page=genesis on the footer section. Works nicely 🙂

    February 18, 2013 at 3:20 pm #21098
    Riavon
    Member

    Thanks, Ipstenu, this is a much more elegant - and properly done - solution!


    Twitter: @riavonentprises

    March 9, 2013 at 7:26 am #25176
    yellowdog
    Member

    I am trying to implement this backstretch

    I have uploaded the .js file and added the code to functions.php but i am stuck at the next part?

     

    How do i use the Block element?

    Damn..this genesis has a learning curve for me!!

     

    September 5, 2013 at 10:10 am #60864
    scoe
    Member

    Wonder if anyone has done with this the new Pro version?

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

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