RickWolff
(Rick Wolff)
April 29, 2016, 8:30pm
1
The maker of a WordPress theme that clearly already incorporates JavaScript has suggested that I enqueue the script. The format for such an edit to functions.php appears in this article in TutsPlus.
So here’s what I’m trying:
<?php
function load_hype() {
wp_register_script( 'woofhomepage_hype_generated_script.js', content_url('/woofhomepage.hyperesources/woofhomepage_hype_generated_script.js').'/HYPE-526.full.min.js'__FILE__) );
wp_enqueue_script('woofhomepage_hype_generated_script.js');
}
add_action('init', 'load_hype');
?>
…and it’s crashing the whole site.
Any clue what I’m doing wrong?
Here’s the site in question, at which I’ve returned a default photo and h1.
DBear
April 29, 2016, 9:25pm
2
Try this, I’m not 100% on enqueing in Wordpress.
<?php
function load_hype() {
wp_register_script('my_script', content_url('/woofhomepage.hyperesources/woofhomepage_hype_generated_script.js', __FILE__), false);
wp_enqueue_script('my_script');
}
add_action( 'wp_enqueue_scripts', 'load_hype' );
?>
I noticed some discrepancies in your code: i.e missing comma and not adding true or false (before footer or in header respectively)
RickWolff
(Rick Wolff)
April 30, 2016, 3:47pm
3
It’s not working. What’s another approach? I’m all out of options.
Daniel
April 30, 2016, 4:23pm
4
It looks like there's a couple 404 errors on that page: http://woof-music.com/wp-content/woofhomepage.hyperesources/woofhomepage_hype_generated_script.js?ver=4.5.1
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (woofhomepage_hype_generated_script.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (HYPE-526.thin.min.js, line 0)
If this doesn't work, you can always make this a part of your theme in a standard way based on these instructions:
The recommended method of embedding a Tumult Hype document in Wordpress is to use the official plugin:
If you’re curious how to embed manually, please watch the video below and read on:
This video covers how to embed a Tumult Hype document within Wordpress:
Keep in mind that the instructions below are for adding a Tumult Hype document to a self-hosted Wordpress installation. Wordpress sites hosted on Wordpress.com are not compatible with Tumult Hype .
Best Practices
Before you begin, make…
DBear
April 30, 2016, 5:09pm
5
Your woofhomepage.hyperesources folder is not in the wp-content section. You either have to use an absolute url (http://woof-music.com/woofhomepage.hyperesources/woofhomepage_hype_generated_script.js ) or place resources folder in wp-content.