Update the Codex-Using Javascript page
-
I’ve implemented a direction that the WordPress give on it’s Using_Javacript page and it didn’t work. I thought there was something wrong with my code or page or setup or something but the direction
To use Javascript repeatedly within your site, you can either set the call for the Javascript, or the script itself, in the head of your header.php template file, between the meta tags and the style sheet link, no differently than you would if you were using Javascript in any HTML page. To “load” the Javascript file into your site, in the head, add something like this:
‘<script type=”text/javascript” src=”/scripts/emailpage.js”></script>’
is totally incorrect.How frustrating!
How do we get someone to change the codex? For those who want to know, you can use this line of code.
‘<script type=”text/javascript” src=”<?php bloginfo(‘template_url’); ?>/js/maxrating.js”></script>’
The “template_url” will read to the root directory of your current template and them after the closing of the php code use a forward slash/path/to/your/file.js. If your javascript file isn’t in a sub-directory and in the root all you need is the forward slash “/” and the name of the file.I hope this saves someone hours of frustration!
The topic ‘Update the Codex-Using Javascript page’ is closed to new replies.