0

Homepage has a backstretch image which is also active throughout the site on posts and pages. How can I keep the backstretch on the homepage but hide it on posts or pages? pulled this from the functions.php thinking this might be where I'd need to start:

//* Load scripts only if custom backstretch image is being used
if ( ! empty( $image ) ) {

        wp_enqueue_script( 'theme-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
        wp_enqueue_script( 'theme-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'theme-backstretch' ), '1.0.0' );

        wp_localize_script( 'theme-backstretch-set', 'BackStretchImg', array( 'src' => str_replace( 'http:', '', $image ) ) );

    }

}
4
  • 2
    You could add a conditional tag after the function if ( is_front_page(). Please ask this question on the SP forums as its not covered here on SE. Thanks Feb 17, 2015 at 17:17
  • Thanks Brad! I use the SP forums, however I'm confused (and I'm totally new here so please correct me if I'm wrong) but isn't this a PHP question?
    – Chris
    Feb 18, 2015 at 15:54
  • Hi Chris. Questions specifically relating to PHP code are also not covered. So are questions relating to the modification of commercial themes and plugins. Questions should relate specifically to WordPress. wordpress.stackexchange.com/help/on-topic Feb 18, 2015 at 16:22
  • this is a WP specific question and is acceptable here Feb 19, 2015 at 19:26

1 Answer 1

0

Add a conditional to the existing if-statement checking for is_front_page() (or is_home(), depending on your needs):

if ( ! empty( $image ) && is_front_page() ) {
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.