jQuery selectable() function won’t work in wordpress

I always refer to to this blogpost about how to including jQuery code in WordPress. It shows you how to use noConflict within your javascript-code. var $j = jQuery.noConflict(); $j(function(){ // YOUR CODE HERE } } Also make sure that the jQuery library is included on the frontside of your WordPress installation with the wp_enqueue_script-function. … Read more

jQuery script doesn’t work on WordPress

Initialize the Scroll to Top script from within another JavaScript file. I’m assuming that jquery.backtotoplink.js is coming from a third party and that it should not be modified. For example, in a theme, the JavaScript could be enqueued like this: function wpse247853_scripts() { // jquery.backtotoplink.js depends on jquery wp_enqueue_script( ‘scrolltotop’, get_template_directory_uri() . ‘/js/jquery.backtotoplink.js’, array( ‘jquery’ … Read more

jQuery don’t working

Don’t load jQuery that way. It comes built into WordPress, so what you really want to do is tell WordPress that (1) your Javascript file should be loaded, and (2) it relies on jQuery being loaded. You do this with wp_enqueue_script. So put this in your functions.php file, replacing the path in quotes with the … Read more

WordPress jQuery crash [closed]

The reason you are getting the error is that you are trying to bind a JavaScript function to a WordPress PHP hook. Bind your JavaScript handler to the form’s submit event: $( “#your-form” ).submit(function( event ) { //Select checkboxes by id var $checkboxes = $(‘input[id=checkboxprice]’); //Set event $checkboxes.on(‘change’, function () { var totalPrice = 0; … Read more

How to call custom jQuery plugins into the customizer controls

First, in order to enqueue JS in the customizer controls, you need to use the customize_controls_enqueue_scripts action. This is different than the action used to enqueue scripts into the customizer preview, which is what themes normally do via customize_preview_init or wp_enqueue_scripts. So in your snippet above, replace customize_preview_init with customize_controls_enqueue_scripts. Secondly, in order to extend … Read more

Can’t delete the default jQuery in the theme

An example on how to deregister a WordPress built-in library and load your own: function load_custom_scripts() { wp_deregister_script( ‘jquery’ ); wp_register_script(‘jquery’, ‘//code.jquery.com/jquery-2.2.4.min.js’, array(), ‘2.2.4’, true); // true will place script in the footer wp_enqueue_script( ‘jquery’ ); } if(!is_admin()) { add_action(‘wp_enqueue_scripts’, ‘load_custom_scripts’, 99); }

Adding custom cart price with Ajax in wordpress

Try to change your add_custom_price_callback() as follows. Untested but should work. function add_custom_price_callback() { $custom_price = intval($_POST[‘p_m’]); $target_product_id = intval($_POST[‘s_o_v’]); foreach ( WC()->cart->get_cart() as $key=>$value ) { //Single product if ( $value[‘product_id’] == $target_product_id ) { $value[‘data’]->set_price($custom_price); } //For variation if ( $value[‘variation_id’] == $target_product_id ) { $value[‘data’]->set_price($custom_price); } } //to check if is work … Read more

fill form fields with ajax response

First, I can count on one finger the number of times A code which was developed in the hope of being “reusable” was actually reused. Write the code to the specification you can test against. “Reusable” is not a specification you can test against until you have a proper idea what will you need in … Read more

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