• 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

loading script per page

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 › loading script per page

This topic is: not resolved

Tagged: enqueue, is_page, jquery

  • This topic has 1 reply, 2 voices, and was last updated 7 years, 10 months ago by Susan.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • February 10, 2015 at 6:23 am #140314
    yogidev
    Member

    Hi,

    I have searched around and tried a few different things but cant get this to work.

    I would like to load a .js file to handle some functionality only for my 'videos' page.

    I tried this in my functions.php:

    add_action('genesis_meta', 'video_js');
    function video_js() {
     if(is_page('videos')) {
        wp_register_script( 'video', '/lib/js/video.js');
        wp_enqueue_script( 'video' );
     }
    }

    and:

    function my_scripts_method() {
    	wp_enqueue_script(
    		'custom-script',
    		get_template_directory_uri() . '/lib/js/video.js', array('jquery')
    	);
    }
    if(is_page( 'videos' ) ) add_action('wp_enqueue_scripts', 'my_scripts_method');

    'videos' is the page slug.

    I get this error displayed 3 times for the same line:
    NOTICE Error: [8] unserialize() [function.unserialize]: Error at offset 110 of 704 bytes

    Could anyone shed any light on the best way to do this, and why it is not working with either of the above code?

    Also, what is best practice for using JQuery? Should it work if I replace $ with $j?

    May 7, 2015 at 7:42 am #150612
    Susan
    Moderator

    As you posted this a while ago, I hope you were able to get your issue resolved. If it is resolved, please mark this thread as "resolved", so it can be closed.

    If you are still having issues, report back here, and I will try to escalate.

  • 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