289 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+3 more
AkinGn says

A new thread was necessary for this issue thanks to sevenspark for helping me out but wanting more help from him could be abusing :))

So for example in order to get jcarousel working we normally need 3 scripts to include: jquery library, jcarousel and if we want to use seperately a trigger file that would be something like config.js. when I include these 3 between <script></script> tags (in header.php file), it works perfectly. But when I try wp_enque_script method by adding the code below functions.php:

<?php function my_load_scripts(){
wp_enqueue_script( 'jquery' );

wp_enqueue_script('jcarousellite', get_bloginfo('template_directory') . '/js/jcarousellite_1.0.1.js', array('jquery'));

wp_enqueue_script('config', get_bloginfo('template_directory') . '/js/config.js' , array('jquery', 'jcarousellite));

add_action('wp_head', 'my_load_scripts');

?>

It doesn’t work.. I thought it’s enough to add the code above to functions.php, what am I missing/doing wrong here?

1799 posts
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
BroOf says

You forgot an } bracket. You open the function my_load_scripts() but you doesn’t close it.

1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says

In addition to what BroOf said, it is probably better to use the wp_enqueue_scripts action instead of wp_head, e.g.

add_action(‘wp_enqueue_scripts’, ‘my_load_scripts’);

289 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+3 more
AkinGn says

You forgot an } bracket. You open the function my_load_scripts() but you doesn’t close it.

I think I missed it while pasting I have it at my original code. but thanks for the heads up. and one more question: is that it that I have to do to enqueue scripts? I’m not missing something or forgetting calling some function somewhere (for example at header) etc ?

1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says


You forgot an } bracket. You open the function my_load_scripts() but you doesn’t close it.
I think I missed it while pasting I have it at my original code. but thanks for the heads up. and one more question: is that it that I have to do to enqueue scripts? I’m not missing something or forgetting calling some function somewhere (for example at header) etc ?

That’s all you have to do, plus you have to change the wp_head to something else, like wp_enqueue_scripts or init.

Check out this link: http://wordpress.org/support/topic/wp_head-wp_enqueue_script-problem-loading-the-script-into-head-section

289 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+3 more
AkinGn says

Thanks so much fillerspace, I hope I can figure it out. :)

289 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+3 more
AkinGn says

I managed to get some of the scripts to work via deregistering and re-registering the jquery, hopefully I’รถ gonna get the other ones working too, thanks guys :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by