Javascript Per Page adds a custom javascript file to all of the pages on your WordPress install with options to check for the existence of the javascript file before adding.
Allows for adding IE specific javascript all the way back to version 6. Just enable in the plugin options and add the javascript files to your theme directory.
Javascript Per Page also allows adding of an iOS specific javascript file. Simply enable in the plugin options and add the javascript to your theme directory.
This plugin supports use with custom post types, category, and tag pages.
- Upload the plugin to the
/wp-content/plugins/
directory
- Activate the plugin through the 'Plugins' menu in WordPress
To use this plugin, just add javascript files in the following formats to your theme's base directory or a "js" subdirectory inside your theme's base directory:
- For pages create a file called page-[page_name].js where "[page_name]" is replaced with the slug of the page. Eg: page-about.js.
- For author pages create a file called user.js and for individual user pages user-[username].js where "[username]" is replaced with the user's login name.
- For different post types user [post_type].js where "[post_type]" is replaced with the name of the custom post type. You can also use just 'post' for regular posts. Eg. post.js.
- For individual posts use [post_type]-[post_name].js where "[post_type]" is replaced with the name of the custom post type or just 'post' for regular posts, and "[post_name]" is the slug of the post. Eg. post-10-tips-for-baking-pies.js, or, say if you had a "recipes" post type use something like recipes-classic-french-cheesecake.js.
- For tag pages use tag.js or tag-[tag_name].js where "[tag_name]" is replaced with the slug of the tag
- For category pages use category.js or category-[category_name].js where "[category_name]" is replaced with the slug of the category
- For archive pages use archive.js
- For home and front pages use home.js and front-page.js respectively
- To activate IE specific javascript files just create js files with the following naming: ie.js (covers all IE versions), ie8.js (covers IE 8 and below), ie7.js (covers IE 7 and below), ie6.js (covers IE 6 and below).
- To activate a iOS specific javascript create ios.js and enable in the plugin options.
NOTE: You can place your custom JS files in either the base directory of your theme, or in a "js" subdirectory inside your theme, but try to be consistent with where you place them.