Applying jquery to WordPress admin edit.php

The previous answer works good with my example above using this hook: add_action( ‘admin_head’, ‘woocommerce_admin_init’ ); function woocommerce_admin_init() { $screen = get_current_screen(); if ( $screen->post_type == “shop_order” ) { ?> <script type=”text/javascript”> jQuery(document).ready(function ($) { $(“.edit_address”).click(); $(“.add-line-item”).click(); }); </script> <?php } }

Live search from database table

So in php it needs to be: $query = ‘SELECT Location FROM locations’; $result = mysqli_query($link, $query); $rows = array(); while($r = mysqli_fetch_assoc($result)) { $rows[] = $r[‘Location’]; } and jquery ui autocomplete: $(“#location1”).autocomplete({ source: <?php echo json_encode($rows);?>, // this part is only if you want to force autocomplete select change: function (event, ui) { if(!ui.item){ … Read more

Delete post image attachments with jQuery from the front end

Now you need to handle the AJAX call in PHP. add_action( ‘wp_ajax_delete_attachment’, ‘delete_attachment’ ); function delete_attachment( $post ) { //echo $_POST[‘att_ID’]; $msg = ‘Attachment ID [‘ . $_POST[‘att_ID’] . ‘] has been deleted!’; if( wp_delete_attachment( $_POST[‘att_ID’], true )) { echo $msg; } die(); } As for your event, just add it to the click function … Read more

WordPress can’t get jquery/unslider to work

$(document).ready(function(){ alert(“test”); }); It could be that your jQuery is working in compatibility mode. Try replacing $ with jQuery: jQuery(document).ready(function(){ alert(“test”); }); Edit: As per the author edit on the post: jQuery(document).ready(function(){ jQuery(‘.automatic-slider’).unslider({ autoplay: true }); });

Disable submit button order

Fixed the issue. Was calling the incorrect IDs. Below is the code I used for anybody else wanting to achieve the same outcome. <script type=”text/javascript” charset=”utf-8″> jQuery(document).ready(function($){ $(“.button#place_order”).click(function () { $(“.button#place_order”).attr(“disabled”, true); $(‘.checkout’).submit(); }); }); </script>

JS file is not loading when i put wp_head() and wp_footer

Something more like this… function wpdocs_theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); // only enqueue jquery if it is not already enqueued! if (!wp_script_is(‘jquery’,’enqueued’)) { wp_enqueue_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js’, array(), true ); } // note: last parameter only needed here if custom.js actually needs jquery wp_enqueue_script( ‘script-name1’, get_stylesheet_directory_uri() . ‘/js/custom.js’, array(‘jquery’) ); // all other scripts clearly … Read more

Custom AJAX form not working async

First probable issue: You’re using name in the form. You should not, since it’s a reserved term in WordPress. Second probable issue: You’re using a form action URL of <?php echo get_template_directory_uri(); ?>/assets/php/process-contact.php. That will break if you use any WordPress functions (or functions defined in functions.php and plugins). This is the correct way to … Read more