• 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

Conditional add script to footer:

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 › Conditional add script to footer:

This topic is: not resolved

Tagged: Add scripts, conditional, enqueue scripts, footer, js, scripts

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 4 months ago by Sridhar Katakam.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • October 24, 2013 at 6:16 am #68600
    jgk
    Member

    Hi, I'm attempting to add some js scripts to the footer, but only on one page of the site. I cannot find a code snippet for this online. Thanks so much for any help. Here's what I have pasted into functions.php that isn't working now:

    
    add_action( 'genesis_after_footer', 'scripts_footer_services_page' );
    /**
     * Enqueue Scripts
     */
    
    function scripts_footer_services_page() {
    
    	if ( is_single('482') ) {
          	wp_enqueue_script( 'services-1', get_stylesheet_directory_uri() . '/js/services-1.js', array( 'jquery' ), '', true );
    		wp_enqueue_script( 'services-2', get_stylesheet_directory_uri() . '/js/services-2.js', array( 'jquery' ), '', true );
    	}
    }
    http://studioissa.com/services/
    October 24, 2013 at 7:27 am #68608
    Sridhar Katakam
    Participant

    Change that to

    //* Enqueue scripts
    add_action( 'wp_enqueue_scripts', 'scripts_footer_services_page' );
    function scripts_footer_services_page() {
    
    	if ( is_single('482') ) {
    		wp_enqueue_script( 'services-1', get_stylesheet_directory_uri() . '/js/services-1.js', array( 'jquery' ), '', true );
    		wp_enqueue_script( 'services-2', get_stylesheet_directory_uri() . '/js/services-2.js', array( 'jquery' ), '', true );
    	}
    }

    Genesis Tutorials | Follow me on Twitter

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