-
▼
2012
(336)
-
▼
May
(23)
- How to Get the Title of the Blog in WordPress
- How to Convert WordPress Template for TypePad
- How to Log Into MooTools for WordPress
- How to Use WordPress Comment Plugins to Improve a ...
- How to Organize Your WordPress Blog Using Pages
- How to Import All Comments From WordPress to Blue ...
- How to Make My Pictures Not Stretch in WordPress
- How to Install Something between the Head Tags in ...
- How to Remove Topics From a WordPress Post
- How to Copy a WordPress Blog to LocalHost
- How to Disable WordPress Widgets in MySQL
- How to Upload a YouTube Video to WordPress
- How to Disable the Automatic Date on a WordPress Blog
- How to Empty Trash Posts in WordPress
- How to Change My Self
- How to Edit a WordPress Header in cPanel
- How to Manually Remove WordPress From HostGator
- How to Edit Wordpress Themes
- How to Install WordPress for a Blog on Ubuntu 10.04
- How to Add a Page Template in WordPress
- How to Import a Word Document Into a WordPress Blog
- How to Use JavaScript With WordPress
- How to Display Excerpts on WordPress Posts
-
▼
May
(23)
adsense
How to Use JavaScript With WordPress
1. Open up the 'header.php' file for your theme in a code editor. This file is found in the following location:/your-site/wp-content/themes/theme-name/Look for the ending
tag and check that the code
appears above any
tags but below all other tags between
and
. If it is not there, add that line.
2. Add your
tags to include the JavaScripts you wish to use. When the JavaScript is in an external .JS file, include it like this:
/yourscript.js'>
The above code uses
to tell WordPress to look inside your theme folder for the JavaScript. Many developers put all scripts into a folder called 'js' or 'src' to keep things organized. In such a case, remember to include that folder in the path to your script. All JavaScript that is directly on the page goes between
and
tags.
3. When using a JavaSript that depends on a library such as jQuery, MooTools or YUI, you must first enqueue that library. Static HTML websites need you to include libraries as scripts, but WordPress already contains them. Here is an example of how to enqueue jQuery:
Place the enqueue code above
to make it work properly. After enqueing, you can then include JavaScripts that use that library the same way you would include other JavaScripts in WordPress.
6:45 AM | Filed Under | 0 Comments
Post a Comment