Title: Problems using wp_enqueue_script Linked script not working
Last modified: August 22, 2016

---

# Problems using wp_enqueue_script Linked script not working

 *  Resolved [kscomp0](https://wordpress.org/support/users/kscomp0/)
 * (@kscomp0)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/problems-using-wp_enqueue_script-linked-script-not-working/)
 * I am trying to load some javascript that modifies table data on select pages.
   
   The javascript is contained in an external file that is located in the js folder
   under a child theme (hueman-child-master).
 * My understanding is that wp_enqueue_script and wp_register_script are the proper
   ways to load javascript onto wordpress pages.
 * I can get the script to work if I use a plugin that adds the whole script to 
   the footer, but I wanted to add it without using an additional plugin.
    Eventually
   I was going to use a shortcode to run wp_enqueue_script, but for now I have it
   set up as follows in the child theme’s php file:
 *     ```
       <?php
       /* ------------------------------------------------------------------------- *
        *  Custom functions
       /* ------------------------------------------------------------------------- */
   
       	// Add your custom functions here, or overwrite existing ones. Read more how to use:
       	// http://codex.wordpress.org/Child_Themes
       function register_my_scripts() {
            wp_register_script ( 'tablechanger', plugins_url( '/js/tablechanger.js', __FILE__ ), array(), '1.0', true );
            wp_enqueue_script ( 'tablechanger' );
       } 
   
       add_action( 'wp_enqueue_scripts', 'register_my_scripts' ); 
   
       /* add_shortcode ( 'tablechanger', 'tablechanger_handler' );
       function tablechanger_handler() {
            wp_enqueue_script ( 'tablechanger' );
       } */
       ?>
       ```
   
 * The script gets registered, or at least its link shows up in the page, but it
   doesn’t run.
    Do you have any suggestions? This is being done on a localhost 
   for now.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Lucas Karpiuk](https://wordpress.org/support/users/karpstrucking/)
 * (@karpstrucking)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/problems-using-wp_enqueue_script-linked-script-not-working/#post-5708210)
 * you’re using `plugins_url` in a child theme
 *  Thread Starter [kscomp0](https://wordpress.org/support/users/kscomp0/)
 * (@kscomp0)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/problems-using-wp_enqueue_script-linked-script-not-working/#post-5708211)
 * Thanks, Karpstrucking. What should I use to get the path?
 *  Thread Starter [kscomp0](https://wordpress.org/support/users/kscomp0/)
 * (@kscomp0)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/problems-using-wp_enqueue_script-linked-script-not-working/#post-5708228)
 * Changed plugin_url() to get_stylesheet_directory_uri() and that worked.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problems using wp_enqueue_script Linked script not working’ is closed
to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [kscomp0](https://wordpress.org/support/users/kscomp0/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/problems-using-wp_enqueue_script-linked-script-not-working/#post-5708228)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
