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

ajax stopped working when not logged in?

Edit: I’ve kept my original answer below, however, I’m not sure what I was thinking… You should never need to trigger do_action( ‘wp_ajax…’ ). While I can’t be sure what the issue is, is the code in the question is roughly ok (I think $_POST should be $_GET with .getJSON). Try putting this at the … 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 to manage ajax calls and JSON in wordpress

Ajax Handler It is indeed a bit confusing that the Ajax handler is in the wp-admin/ directory, but yes, you can and should use it for non-admin requests too. You then register a handler for the wp_ajax_nopriv_[action] hook, instead of the normal wp_ajax_[action]. In this case you only have to follow the first lines of … Read more

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

Using WordPress 3.5 Media Uploader in meta box?

To get you started, the basic functions and overrides as far as I know currently.There might be better solutions, but I only had two days with 3.5 yet: // open modal – bind this to your button if ( typeof wp !== ‘undefined’ && wp.media && wp.media.editor ) wp.media.editor.open( ##unique_id_here## ); // backup of original … 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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)