WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this js function (the textualizer.js is external) but I can't make it works on WordPress. Any help?

I already added

wp_register_script( 'textualizer', WP_THEME_URL . '/assets/js/textualizer.js');
wp_enqueue_script( 'textualizer' );

to theme functions.

What am I doing wrong? I know it's probably simple, but I can't figure it out.

EDIT: i changed the function in functions.php, a user in irc channel told me that i was missing the correct action hook. still doesn't work... http://pastebin.com/L8ZRSvzU

share|improve this question

closed as too localized by Chip Bennett, toscho Mar 5 '13 at 16:57

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Where are you calling this code? Does a script link get output in the rendered source? (Side note: use **get_template_directory_uri() ** rather than WP_THEME_URL.) – Chip Bennett Mar 4 '13 at 18:13
You can see it in the pastebin in EDIT. I put the function in functions.php, then i use it in a template page. the console in the developer tool give me the error: Uncaught TypeError: Object function (j,s){return new b.fn.init(j,s)} has no method 'Deferred' and it links me to the plugin file, that should work. – Novalgina2Fast Mar 5 '13 at 16:02
Close-voted as too localized. Your problem is that you're deregistering core jQuery and registering an older version. – Chip Bennett Mar 5 '13 at 16:45
done, it works now. thanks – Novalgina2Fast Mar 5 '13 at 16:54
up vote 2 down vote accepted

Using Google with the error message you posted in your comment, Google show me this: The Deferred object, introduced in jQuery 1.5

Your source code says, that you use jQuery 1.4.4.

jQuery is bundled with WordPress and it's version is 1.8.3. Please use the bundled jQuery and not one from an CDN.

share|improve this answer
Yep; this is the problem: <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js?ver=3.5.1'>‌​</script>. Where do you deregister core jQuery and register jQuery 1.4.4? Wherever it is, get rid of it. – Chip Bennett Mar 5 '13 at 16:44
Thanks again. yeah, i figured out, but I'm using the jQuery bundled with WP. I use the lib with '<?php wp_enqueue_script('jquery'); ?>' in the header, and in my template i just use get_header. So, where the plugin is using jQuery 1.4.4. ? some way to know? ( firebug? ) I'm still new to this. – Novalgina2Fast Mar 5 '13 at 16:44

textualizer() is a jQuery plugin, so you should set a dependency to jQuery

  get_template_directory_uri() . '/assets/js/textualizer.js',
  array( 'jquery' ),
  false, // no version
  true // load into footer

Even if you load jQuery first, the dependency make sure the jQuery plugin is loaded after jQuery.

And it is always a good idea to use a console like Firebug in FireFox or the build in developer tools in Chrome. The console list javascript errors which are very important informations.

share|improve this answer
Thanks, but still doesn't work. you were right, so i made some change: pastebin.com/V6q6s0EJ Javascript console give me the error: TypeError: b.Deferred is not a function. The page I'm talking about: glenlasio.com/statement – Novalgina2Fast Mar 5 '13 at 14:00

Not quite sure where WP_THEME_URL links to, but here is an idea. Depending on whether you're calling the file of a child or parent theme, you must use the accurate path.

For Example, if you want to refference the parent directory use get_template_directory_uri() which is always going to look inside the parent directory.

Or if you want to specify that the file is in the child theme use get_stylesheet_directory_uri(), which is gonna fallback to the parent if the child file does not exsist.

Just replace WP_THEME_URL and see if that helps.

share|improve this answer
done it, still doesn't work. thanks anyway – Novalgina2Fast Mar 5 '13 at 16:02

Everythings works fine. The problem was the library too old. Thanks to everyone!

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.