How to correctly load this jquery script through the file functions.php?

You don’t need to include jquery-ui and jquery-ui.min either of them is sufficient . Also jquery and jquery-ui are already included in WordPress. Try this wp_enqueue_script( ‘jquery’); wp_enqueue_script( ‘jquery-ui-core’); wp_enqueue_script( ‘qs.slider’, get_template_directory_uri() . ‘/layout/assets/js/qs.slider.js’, array(‘jquery’,’jquery-ui-core’), ”, true ); wp_enqueue_script( ‘qs.slider.init’, get_template_directory_uri() . ‘/layout/assets/js/qs.slider.init.js’, array(‘jquery’,’jquery-ui-core’), ”, true ); The above code will make sure jquery and … Read more

Populate an array from the loop, and then read the array into JS

It’s because you’re running the localize script inside the loop. Instead, store the array of ids etc, and then run localize script outside/after you set it up. All the localize script really does is inject the params you pass into it into the global scope of js/jquery, allowing you to reference them. However, localize script … Read more

Modify the href attribute of tag dynamically in WordPress

Try this (pure JavaScript): var allBtns = document.getElementsByClassName(‘nectar-button’); function preventDefaultOpenCustomUrl(event) { event.preventDefault(); var price = document.getElementById(“fieldname9_1″).value; var url=”https://na2.docusign.net/member/PowerFormSigning.aspx?PowerFormId=df6fbf3d-6f5d-4c48-8965-f4fa810099f4&Institutional_Buyer_AnnualPrice=” + price; window.open(url); } ; for (i = 0; i < allBtns.length; i++) { allBtns[i].addEventListener(“click”, preventDefaultOpenCustomUrl); } this is adding the event to all buttons with that classname, with Jquery: (function ($) { $(‘.nectar-button’).on(‘click’, function (e) { … Read more

Get child-pages slugs of current page into js-file

I just found what is arguably a cleaner way to do this…thanks to this other WPSE question How do I add a php statement to a jQuery string. I never new about wp_localize_script() until reading the answer to that question (I love WPSE :-). PHP add_action (‘wp_enqueue_scripts’, ‘localize_js’) ; function localize_js () { global $post … Read more

Display text of price (minus 20%) on every product page in a sentence.

Assuming you would put this in a woocommerce template file, wherever you want it to display: <?php global $product; $regular_price = esc_attr( $product->get_display_price() ); $discount = 20; $currency = esc_attr( get_woocommerce_currency() ); $new_price = ($regular_price * $discount) / 100; echo ‘Get this product for ‘.$new_price.$currency.’ with (Promo code)’; ?> Untested, but should do the trick.

Facebook Quote Plugin for Blockquote?

Kept on searching and found that I can just add a url parameter for the quote (source): URL (of course) → u custom image → picture custom title → title custom quote → quote custom description → description Example: https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fstackoverflow.com%2Fq%2F20956229%2F1101509&picture=http%3A%2F%2Fwww.applezein.net%2Fwordpress%2Fwp-content%2Fuploads%2F2015%2F03%2Ffacebook-logo.jpg&title=A+nice+question+about+Facebook&quote=Does+anyone+know+if+there+have+been+recent+changes+which+could+have+suddenly+stopped+this+from+working%3F&description=Apparently%2C+the+accepted+answer+is+not+correct.

Widget outputting JS as plain text

Did you try to put propper <script>tags around your code? So instead of inserting the raw JS code, I suppose you encapsule the code it like this: <script> // JS goes here </script> This at least works with the common text widget.