Tag Info

New answers tagged


As toscho pointed out, use jQuery(document).ready(function($) { ... }); instead of $( function() { ... }); Edit: Main problem is WP rich text editor escaping your html <script> tags. See https://codex.wordpress.org/Using_Javascript at the bottom of the page for a plugin-based workaround to turn off formating for specific posts/pages, allowing you to ...


JS variables are not directly replaced as you are expecting. Localizing in your code is correct. When you do var jsonPath = itajax.ajaxurl;, value of itajax.ajaxurl is assigned to the variable jsonPath. If you debug this variable in the console, you will get the correct value. console.log(jsonPath);


I found an other way that works well for me: When initializing the plugin, do not enqueue your scripts and styles, but register them with wp_register_style and wp_register_script. Next you can load the script/style on demand. For example when you render a shortcode with wp_enqueue_style("your_style") and wp_enqueue_script("your_script"). This way the ...

Top 50 recent answers are included