• 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 get this jQuery to work

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 get this jQuery to work

This topic is: resolved
  • This topic has 3 replies, 2 voices, and was last updated 11 years, 10 months ago by Ben @ Inbound Creative.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • January 4, 2014 at 6:23 am #83096
    Ben @ Inbound Creative
    Member

    Hi guys and girls,

    I've found a solution to a problem I'm having on Stack Overflow.

    The jQuery works perfectly for what I need, but I have no idea how to save it for use on my site.

    I know how to enqueue the script. I'm just not sure what is supposed to go around the jQuery for it to work.

    Any help would be appreciated.

    Here's the code within a demo here - http://jsfiddle.net/VB4QC/


    Award winning web design in Liverpool | UK based Genesis Framework web designer and developer

    January 4, 2014 at 7:29 am #83105
    Sridhar Katakam
    Participant

    Create a file named say, term-rotator.js under js directory (create if not existing) in your child theme having this code:

    jQuery(document).ready(function($) {
    
    	var terms = ["term 1", "term 2", "term 3"];
    
    	function rotateTerm() {
    		var ct = $("#rotate").data("term") || 0;
    		$("#rotate").data("term", ct == terms.length -1 ? 0 : ct + 1).text(terms[ct]).fadeIn().delay(2000).fadeOut(200, rotateTerm);
    	}
    	$(rotateTerm);
    
    });

    Then add this in child theme's functions.php:

    //* 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 );
    
    }

    Genesis Tutorials | Follow me on Twitter

    January 4, 2014 at 10:56 am #83165
    Ben @ Inbound Creative
    Member

    Hi Sridhar,

    Thanks for taking the time to help.

    I've done this and it hasn't worked.

    Is there a chance that because this is being executed out of the loop that it isn't working.

    This is the full code of the homepage template

    <?php
    /*
    Template Name: Home
    */
    
    get_header();
    ?>
    
    <div id="header">
    
    	<a href="/" id="logo">
    	
    		<img src="/images/logo.png" alt="Advice Media">
    		
    	</a>
    
    	<div class="text" role="main">
    		
    		<h1>We create content</h1>
    		<h1>that <span id="rotate">this</span>. Period.</h1>
    		
    		<a href="#contact" id="contactlink">Let's talk</a>
    		
    	</div>
    	
    	<div class="content" id="scrolldown">
    
    		<a href="#start"><img src="/images/arrow.png" alt="Scroll down"></a>
    
    	</div>
    
    </div>

    Award winning web design in Liverpool | UK based Genesis Framework web designer and developer

    January 4, 2014 at 5:02 pm #83266
    Ben @ Inbound Creative
    Member

    Nevermind. It was because I hadn't called the footer on the template. No idea why that was impacting it, but it's working now.


    Award winning web design in Liverpool | UK based Genesis Framework web designer and developer

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

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