jQuery is not defined, working on local server but not online

Add this in functions.php instead of header.php function frontEnd_scripts() { wp_enqueue_script(“jquery”); wp_deregister_script(‘jquery.mobile’); wp_register_script(‘jquery.mobile’, (“//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.js”),array(‘jquery’)); wp_enqueue_script(‘jquery.mobile’); wp_register_style(‘jqm_css’,(‘//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.css’)); wp_enqueue_style(‘jqm_css’); } add_action(‘wp_enqueue_scripts’, ‘frontEnd_scripts’);

Check for Twitter Bootstrap Loaded

There is no good way of doing this. One way is to enumerate the already registered scripts, like this: function yourplugin_add_my_stylesheet() { global $wp_styles; if ( $wp_styles instanceof WP_Styles ) { // enumerate all current styles foreach( $wp_styles->queue as $handle ) { // use the $handle to see if it’s called ‘bootstrap’ $obj = $wp_styles->registered[$handle]; … Read more

Problem enqueuing scripts on not single posts

With a couple minor modifications, I was able to run your function with your desired outcome (sitewide except on single post/cpt pages & in admin area). The current preferred method of returning the stylesheet uri is with the get_stylesheet_directory_uri(), not by using get_bloginfo(‘stylesheet_directory’): From the WordPress Codex Function Reference page: ‘stylesheet_directory’ – Returns the stylesheet … Read more

Understanding wp_enqueue_style

Scripts and styles get output with wp_head and wp_footer functions. If you enqueue a style after wp_head, it will be output in wp_footer, which, while in practice will often work, means the theme’s html will not validate. It’s up to you (or whomever is building a theme/plugin) to enqueue styles early enough to be output … Read more

Enqueueing TinyMCE

You will need to set the third parameter of wp_register_script(), which is the dependency parameter, $deps. In your code, this is currently set to false, which should actually just be left out or set to an empty array, array() if not needed. In your case, you will set this with the handle of the script … Read more

Proper enqueue for child theme functions.php

I was just setting up a parent theme recently and needed to create a snippet for other theme authors to use. These two in combination will load the correct style.css files, and in the correct order (child being loaded after parent). In your parent theme’s functions.php file: function wpse_175802_scripts() { // Load our main stylesheet. … Read more

Where to place add_action when enqueueing?

Makes no difference. Despite the fact add_action doesn’t actually check if the callback is indeed callable (i.e. is a valid function/class/method), PHP will first “load” function and class definitions before executing inline code, hence why you can do something like: wpse_185390_function(); // Perfectly fine, even though the function is defined “afterwards” function wpse_185390_function() { echo … Read more