But I really want to use the variable

You should not use the $ variable for jQuery within WordPress. OK, I know, you've got a good reason. Say for instance, you're copying a jQuery script over from another non-WordPress project and it's proving cumbersome to covert all the $ variables to jQuery or some other custom shortcut variable. Fine. (Never heard of "Find and Replace"?) At any rate, here is an example of how to shortcut jQuery to safely use the $ variable:

The only drawback to the above solution is, I've found it's easy to start working with the $ variable and then forget to encapsulate other scripts in the above jQuery function. If all my jQuery scripts use the jQuery variable or a custom variable (such as $jq), I'm much better at staying in noConflict mode.

Including jQuery in a WordPress plugin

You can include jQuery in a WordPress plugin using any of the earlier mentioned methods. However, you'll need some familiarity working with WordPress plugins. We'll cover this topic in detail by learning more about WordPress plugins later in Chapter 3, Digging Deeper: Understanding jQuery and WordPress Together.

Was this article helpful?

0 0
Blog Your Way To The Top

Blog Your Way To The Top

How Any Business Builder Can Turn A Simple Blog Into A Lead Generating, Organization Cash Cow For Any Home Based Business! Everyone knows that in order to succeed in your home based business or your MLM / Network Marketing business, you need to adopt the latest strategies when it comes to making massive money.

Get My Free Ebook


Post a comment