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 ) ) );

    }

}
  • 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 – Brad Dalton Feb 17 '15 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 '15 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 – Brad Dalton Feb 18 '15 at 16:22
  • this is a WP specific question and is acceptable here – karpstrucking Feb 19 '15 at 19:26
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() ) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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