Disable wordpress from including jQuery in the head section
the following may work function wpdocs_dequeue_script() { wp_dequeue_script( ‘jquery’ ); } add_action( ‘wp_print_scripts’, ‘wpdocs_dequeue_script’, 100 );
the following may work function wpdocs_dequeue_script() { wp_dequeue_script( ‘jquery’ ); } add_action( ‘wp_print_scripts’, ‘wpdocs_dequeue_script’, 100 );
Use script_loader_tag to modify the HTML before printing. apply_filters( ‘script_loader_tag’, string $tag, string $handle, string $src ) add_action( ‘init”https://wordpress.stackexchange.com/questions/236811/,”replace_jquery_src’ ); /** * Modify loaded scripts */ function replace_jquery_src() { if ( ! is_admin() ) { // Remove the default jQuery wp_deregister_script( ‘jquery’ ); // Register our own under ‘jquery’ and enqueue it wp_register_script( ‘jquery”https://wordpress.stackexchange.com/questions/236811/,”http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js’, false, … Read more
You can check is_single before enqueue the js file add_action(‘wp_enqueue_scripts’, ‘_enqueue’); function _enqueue(){ if(is_single(){ wp_enqueue_script(……); } }
The handle for the jQuery dependency is actually, jquery (all lowercase and case sensitivity matters). The complete list of JavaScript handles are documented here in the Theme Developer Handbook.
You’re not hooking the function to wp_ajax correctly. You need to replace the my_action part with your action name that you’re using the in AJAX request. In your case it’s display_user_table. You also need to hook it on to wp_ajax_nopriv so that it works for logged out users. Here’s your hook with those changes: add_action(‘wp_ajax_diplay_user_table’, … Read more
An Ajax call can be sent to anywhere. It can be a server running a PHP, a virtual local route that is simulated using C#, or anything else. So, Ajax does not care what the response is, since it can’t understand it. When you are sending any data back from your server, as long as … Read more
jQuery is not defined This is because the Google CDN Jquery is not in no-conflict mode. Use the following to make sure the included WordPress no-conflict jquery is used in admin. if( !is_admin()){ wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, (“http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”), false, ‘1.4.2’); wp_enqueue_script(‘jquery’); }
I have finally figured out how to do it, and it now works 100%!! Plus it uses the admin-ajax.php so clicking the Remove link there is an ajax request sent to the function that does the deleting of the attachment and returns the message saying it has been deleted. Here’s the code for my solution, … Read more
1. Register jQuery and the plugin within your head wp_register_script( ‘jquery’ ); wp_register_script( ‘your_jquery_plugin’, STYLESHEETPATH, ‘jquery’, ‘0.0’, false ); 2. Register a meta box It should be a simple checkbox. Please do it like it’s described on the codex page for add_meta_box() (don’t just repeat this one here). If you follow the rest, then the … Read more
First of all, if your code (or the theme’s code) is unregistering jQuery and re-registering it from another location (Google), you need to add this somewhere: jQuery.noConflict(); This makes jQuery cooperate with other scripts (i.e. Prototype) that try to define the $ variable globally. WordPress has this line bundled into their version, Google does not. … Read more