0

I am trying to add a custom script via my functions.php file.

Here is the code. First I am loading jQuery and then the script

When I view my source code I can not see a link to the script.

By the way, let me know if you need to see more of my code I wasn't sure how much I should post.

// jQuery
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
   wp_deregister_script('jquery');
   wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
   wp_enqueue_script('jquery');
}

// show Hide
function add_my_script() {
wp_enqueue_script(
    'show-hide', 
    get_template_directory_uri() . '/js/show-hide.js', 
    array('jquery')
);
}

1 Answer 1

1

You're missing:

add_action( 'wp_enqueue_scripts', 'add_my_script' );

to hook add_my_script() function on to action.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.