Add multiple JavaScript files to template header [duplicate]

You can’t have <script> elements within your PHP like that. Either take them out of the PHP delimiters (<?php ?>) or use wp_register_script() and wp_enqueue_script() to get your scripts within WordPress. Update how can i use wp_enqueue_script() with multiple scripts ? wp_register_script( ‘jquery-1.8.2’, get_template_directory_uri() . “https://wordpress.stackexchange.com/scripts/jquery-1.8.2.min.js” ); wp_register_script( ‘contact’, get_template_directory_uri() . ‘/scripts/contact.js’ ); wp_register_script( ‘easing-1.3’, … Read more

How to add additional JavaScript code [duplicate]

Technically yes, you can add those lines to your header.php file just after the wp_head() function and it’ll load the jQuery from a remote source, just like it was on your local machine. If you want to do it properly, take a look at http://codex.wordpress.org/Function_Reference/wp_enqueue_script which will allow you to add it through the wp_head() … Read more

I keep getting Javascript error messages

You have a LOT of plugins on your blog with associated javascript files. The chance that two are conflicting is always present, so you could try and disable the plugins and then enable then one by one (beginning with the most important ones) until you find the one that’s generating errors. That way you can … Read more

How to implement a JavaScript and CSS file for my WordPress homepage?

You would enqueue it, this is how Javascript is added to WordPress properly. This function would typically go in your theme’s functions.php or in a plugin. function my_scripts_intro() { is_front_page(){ wp_enqueue_script( ‘introjs’,’path to ..intro.js’ ); wp_enqueue_style( ‘introcss’,’path to ..intro.css’ ); } } add_action( ‘wp_enqueue_scripts’, ‘my_scripts_intro’ ); To determine the state of the visitor you would … Read more

Execute PHP code in Javascript onclick

In simple terms, window.location.href is javascript, and will run in the browser, but PHP runs on the server. In order to execute update_usermeta() you need to open a page with that block of code on it. The best way to do this from a click is to use AJAX (javascript) to visit the URL on … Read more

WordPress Theme – jQuery JavaScript Library Issue

Not entirely sure what you’re asking but you have to include and register scripts and then enqueue what you require like:- <?php wp_enqueue_script(‘jquery’); ?> (Place immediately before <?php wp_head(); ?>). Which is included with WordPress incidentally. You can read more on wp_enqueue_script for more information on how to use this in your theme. Edit An … Read more