Tag Info

New answers tagged

0

It is not enough to enqueue jquery (or any other library) before your jquery dependent code, but you also need to make sure jquery is loaded before your code is being parsed/run by the browser.


0

function script_that_requires_jquery() { wp_register_script( 'script-with-dependency', 'http://www.example.com/script-with-dependency.js', array( 'jquery' ), '1.0.0', true ); wp_enqueue_script( 'script-with-dependency' ); } add_action( 'wp_enqueue_scripts', 'script_that_requires_jquery' ); This is the correct method to enqueue scripts (and styles ...


1

Something is messing up your queue. Your jQuery URL has 1.8.3 version, while that is neither default in WP 3.9.1 or actual file it points to (1.11.0). Migrate is not showing up for me either, likely because of issues there. Effectively you are missing jQuery.browser because it was removed in version 1.9+ and migrate is not loaded.


2

I have checked your site jQuery migrate is not enqueued as the version of jquery enqueued is 1.8.3 and jquery migrate only works with jquery version above 1.9 Probably your version of wordpress in not the latest one . The version of preetyphoto is outdated too you can use the latest version ...


0

The is_page function accepts any of the page ID, the page title or the page slug. It looks like you're trying to give it an URL fragment instead. You say that 'contact-us' is the page slug for your contact page, so try if (is_page('contact-us')) { without the forward slashes, i.e. passing the page slug, instead.


2

This is not possible the way you think. It would maybe be possible if you use Reflections or debug_backtrace(), but there's no reliable way to do this. WordPress does not keep a stack or queue where it tracks file names. The only thing I could imagine is just hooking into the action and inside wp_enqueue_scripts(): wp_enqueue_scripts and attach a ...


2

Just to chip in,first of all, thanks for the complement, appreciated. You are using a child theme, of which the parent theme should have enqueued the jquery library built into wordpress. Like I said in the post you are refering to, it is bad practice, my emphasis, for any parent theme to not enqueue jquery by default. You have a couple of problems with ...


2

Wordpress has essentially two groups of methods to handle scripts, both of which should be used: wp_register_script Registers a script in Wordpress. It does not get called, it is just available for Wordpress, if it is needed. wp_deregister_script is the exact opposite. It deletes the definitions made in wp_register_script, the script is no longer ...


1

wp_register_script() just adds an entry to an array, it doesn’t do anything resource intensive. See WP_Dependencies::add(). Registering scripts early helps to avoid collisions, so you should do that always on wp_loaded.


1

Your question is a bit broad. We actually have a one question per post policy. I'm going to try to answer though My first question is, shouldn't most themes that you download out there automatically include jQuery in your header anyway? Well, basically correct. So many features today in a theme needs jquery to run properly. I haven't came across a ...


0

I'm NOT actually Answering the question, I'm putting here, how I got my solution without being on that course: First of all, I got the initial solution to the enqueue problem from WPSE answer. It's working like a charm. But the problem of conflicting re-occurred when I tried embedding the Media Uploaded to a field with wp_enqueue_media(), it's not working ...



Top 50 recent answers are included