• 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

load script only on page – small error

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 › General Discussion › load script only on page – small error

This topic is: not resolved

Tagged: script page

  • This topic has 3 replies, 2 voices, and was last updated 8 years, 1 month ago by Brad Dalton.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • August 14, 2015 at 7:54 am #162360
    tussle
    Member

    Hi
    I loaded a simple jquery script into the functions.php file (child) - works fine.
    I want it now to just load on one page, so removed it from functions.php and put it in the script box on one page. It deosn't work.

    I tried wrapping it in <script> tag, nothing.

    Is there something I'm missing? Reading tutorials here says it should work:
    http://wpsites.net/web-design/best-ways-to-load-scripts-in-wordpress/ -

    //* Enqueue Term rotating script
    add_action( 'wp_enqueue_scripts', 'enqueue_term_rotator' );
    function enqueue_term_rotator() {
    
    	wp_enqueue_script( 'term-rotator',  get_stylesheet_directory_uri() . '/js/term-rotator.js', array( 'jquery' ), '1.0.0', true );
    
    }
    
    

    Thanks

    August 14, 2015 at 8:08 am #162362
    Brad Dalton
    Participant

    Add

    is_page('your-page-slug'))

    after the function

    The scripts box won't work with that code so please remove it from the box.


    Tutorials for StudioPress Themes & WooCommerce.

    August 14, 2015 at 9:25 am #162374
    tussle
    Member

    Thank you. Worked with:

    //* Enqueue Term rotating script
    add_action( 'wp_enqueue_scripts', 'enqueue_term_rotator' );
    function enqueue_term_rotator()  {
    if ( is_page('element') )
    	wp_enqueue_script( 'term-rotator',  get_stylesheet_directory_uri() . '/js/term-rotator.js', array( 'jquery' ), '1.0.0', true );
    
    }
    

    Can I suggest a donate button on your site (second time helped).

    Thanks.

    August 14, 2015 at 10:34 am #162385
    Brad Dalton
    Participant

    @tussle Thanks for the positive feedback.


    Tutorials for StudioPress Themes & WooCommerce.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘General Discussion’ 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