Jquery function working in Dev Console but not otherwise [duplicate]

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 insert code. Alternately, add … Read more

Register jQuery – OOP WP

You are setting your script to be added at the wp_head action. jQuery, along with most other scripts, are loaded as part of the wp_enqueue_scripts action. Care to guess which of those comes first? 😉 Edit This is actually not true. jQuery is loaded as part of wp_default_scripts which does take place before wp_head I … Read more

Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?

You’ll need to look at the server side logs to see what’s actually causing the 400. Without this, it’s just conjecture. With it, you should see exactly what’s causing the problem. However, I conjecture that you’re lacking authentication headers, or an authentication request. I’m not seeing anything related to authentication in your AJAX request, and … Read more

Prevent users from adding taxonomy terms

For these situations build your own metabox for the tax terms and use radio or select. My fork of Jared Atchison’s Custom Meta Box class supports custom taxonomy metaboxes. After you get the metabox directory uploaded use this to create your meta box. $prefix = ‘xxx_’; //Add your own unique prefix. $meta_boxes = array(); $meta_boxes[] … Read more

Why Won’t my jQuery Play Nice with WordPress?

WordPress automatically loads jQuery in “no conflict” mode so that it will be compatible with other libraries. This means the $ variable isn’t used for jQuery within WordPress. Rewrite your code to use the full jQuery keyword when you begin your closure like this: jQuery(document).ready(function($) { // … other code in here }); This is … Read more