Using AJAX With WordPress

How to use AJAX with WordPress Here is the simple tutorial to do so. On Client Side (JAVASCRIPT) <script> $(document).on(‘click’, ‘.remove’, function(){ let url = “<?=admin_url(‘admin-ajax.php’)?>”; $.post(url, { action : “ajax_test”, id : “1”, }, function(data,status){ alert(“Data: ” + data + “\nStatus: ” + status); }); }) </script> On Server Side: (In Plugin or function.php […]

Read More

Add Database table on WordPress Activation

It is a good practice to create new table for your plugin when plugin is activated. register_activation_hook is used to fire a custom function when a plugin is acttivated. So here is a simple function which will trigger when plugin is get activated. function create_user_table() { global$wpdb; $charset_collate = $wpdb->get_charset_collate(); $table = $wpdb->prefix.’users’; $sql = […]

Read More