0
votes

So, I've built my own theme for wordpress. Now, I'm trying to put my own plug-in on that theme which requires 3 javascript files. Upon reading the WP-Codex, it tells me the wp_register_script, wp_enqueue_script and add_action methods are the best way to go.

Now, in my plug-in file, I've done things such as:

function register_my_scripts() {
    wp_register_script('script-1', plugins_url('path/to/script-1.js'), array('jquery'));
    wp_register_script('script-2', plugins_url('path/to/script-2.js'));

    wp_enqueue_script('script-1');
    wp_enqueue_script('script-2');
}

add_action('wp_enqueue_scripts', 'register_my_scripts');

Nothing seems to show up on any of my template pages. I've even put this code on the main index page and still nothing. I've written something simple, straight from the codex like: wp_enqueue_script('jquery') on the page and still nothing shows up. Is there something I'm missing here? Why won't html for loading the scripts show up on my page?

Also, I'm running Wordpress 3.5.2

1

1 Answers

0
votes

I enqueue my scripts like this on the functions.php file:

PHP

wp_enqueue_script ('customjs', '/wp-content/themes/blackboard/js/custom.js','','',true);

Please remember that the usage is:

<?php wp_enqueue_script($handle, $src, $deps, $ver, $in_footer); ?>

Try putting the wp_enqueue_script() on your functions.php just as a test. Please check that your path is correct too and check the source code to see if it's printing but just with a wrong path.

Note that the first line of code on this answer is the only thing I need to enqueue the script, nothing else as far as I know.

Let us know if this works for you, cheers.