Run JS function when JQ enqueued

You can’t do that way first you need to enqueue your script using : wp_enqueue_script(‘jquery’); wp_enqueue_script(‘ns-likes-dislikes-for-posts-js’, plugin_dir_url(__FILE__). ‘path/to/your/js/file/from/plugin/directory/custom.js’, array(‘jquery’), ‘1.0’, true); in custom js start writing your js with jquery but you can’t use $, instead use jQuery. if you want to use $ instead of jQuery try this code: (function($){ // enjoy jquery with … Read more

Change quantity via jQuery and disabile quantity field [closed]

If the input is disabled, it is ignored during form submission. You can try to use readonly attribute. As it says in the docs: The difference between disabled and readonly is that read-only controls can still function and are still focusable, whereas disabled controls can not receive focus and are not submitted with the form … Read more

Best way of getting a a series of custom fields into an array?

This way of wokring with slides seems to be as popular as it is terrible… 🙂 I coded something very much like this recently. Basic idea, adjust as needed: $id = get_the_ID(); $slides = array(); $i = 1; foreach( get_post_custom_keys( $id ) as $key ) if ( false !== strpos( $key, ‘slide’ ) ) $slides[$key] … Read more

Problem Implementing parallax in header of bp-default theme

First off — When including Javascript, use a function hooked to the init action in functions.php. See: http://scribu.net/wordpress/optimal-script-loading.html Secondly — The CSS for the BP bar is being effected by something in your theme. If fixing how your Javascript is loading first doesn’t fix that issue, try selecting that object in Firebug (Or Chrome’s developer … Read more

Loading dynamic content with AJAX breaking jQuery

So if you say there are no errors, I’m assumming that your problem is the AJAX request changing the DOM, and your scripts being loaded before that. If the document changes, you’ll need to tell your scripts that, so they will fire their events on the new content. So: Either you reload all scripts again … Read more

Having trouble setting / modifying cookies

if (getCookie($(this).attr(“id”)) == true) { The above code will NEVER evaluate as true because cookie values are stored as strings. You are trying to store a boolean value, which is converted to a string when it is written to the cookie. When the browser reads the cookie value, it is also read as a string. … Read more

Loading a newer version of jQuery within WordPress

To replace the default jQuery url, do: wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ‘your custom url’, … ); Then call wp_enqueue_script( ‘jquery’ ); as usual. Note that various pages in the WP admin might not be compatible with never versions of jQuery, not to mention plugin scripts.