Using jQuery to delete data stored in wp_options

Ajax in WordPress works by sending an HTTP post to /wp-admin/admin-ajax.php (by default) that then fires the corresponding hook. So, you attach some jquery to an event triggered by your delete button, which then posts to admin-ajax.php, which has an action, say, delete_my_options(), which actually runs the php to delete. Then, you have a function, … Read more

how to remove default jquery and add js in footer?

This will do the trick when added to your functions file: if (!is_admin()) add_action(“wp_enqueue_scripts”, “my_jquery_enqueue”, 11); function my_jquery_enqueue() { wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, “//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”, false, null); wp_enqueue_script(‘jquery’); }

How do I make script load after jquery?

You have a typo in your code. It should be: function load_my_script(){ wp_register_script( ‘my_script’, get_template_directory_uri() . ‘/js/myscript.js’, array( ‘jquery’ ) ); wp_enqueue_script( ‘my_script’ ); } add_action(‘wp_enqueue_scripts’, ‘load_my_script’); The jQuery dependency needs to be an array(), not just a string. This will force your script to load after jQuery.

Is jQuery included in WordPress by default?

Yes, jQuery is part of WordPress core. But–it can become outdated, because jQuery updates can happen in between WP releases. The recent release of WordPress does use a very recent version of jQuery. By default, wp_enqueue_script(‘jquery’) grabs jQuery from the core at /wp-includes/js/jquery/jquery.js. The “correct” way to add jQuery to your WP site is: function … Read more

How to save the state of a drag and drop jQuery UI Sortables front end layout editor?

Brady is correct that the best way to handle saving and displaying of custom post type orders is by using the menu_order property Here’s the jquery to make the list sortable and to pass the data via ajax to wordpress: jQuery(document).ready(function($) { var itemList = $(‘#sortable’); itemList.sortable({ update: function(event, ui) { $(‘#loading-animation’).show(); // Show the … Read more

I want to enqueue a .js file to my child theme

Here’s a working example: add_action( ‘wp_enqueue_scripts’, ‘menu_scripts’ ); function menu_scripts() { wp_enqueue_script( ‘responsive-menu’, get_bloginfo( ‘stylesheet_directory’ ) . ‘/js/responsive-menu.js’, array( ‘jquery’ ), ‘1.0.0’ ); wp_enqueue_script( ‘custom-script’, get_stylesheet_directory_uri() . ‘/js/custom_script.js’, array( ‘jquery’ ) ); } Or like this which apparently loads faster: function my_scripts_method() { wp_enqueue_script( ‘custom-script’, get_stylesheet_directory_uri() . ‘/js/custom_script.js’, array( ‘jquery’ ) ); } add_action( ‘wp_enqueue_scripts’, … Read more