HomePHP Page 4 - Standards-compliant Link Targets with Wordpress
Putting it all together - PHP
Wordpress is an extremely popular site blogging software written in PHP. It does a great job of creating standards-compliant web sites. Plus it’s a good idea to continue with that effort when adding modifications.
The Wordpress plugin we created will work as soon as it is enabled in the Wordpress administration area. The JavaScript, however, needs to be enabled. In order to do this, we need to add a reference to it in our web site template.
Either edit your site template manually or through the Wordpress admin area. Open the header.php file associated with your current template, if there is one. If not, apply this to the default header.php file found in the /plugins/default folder.
Add the line above anywhere between the <head> and </head> tags so that the external JavaScript is loaded with your pages.
The src needs to be either relative to the current page or absolute to the JavaScript file you uploaded previously. Be very careful when using relative URLs. In Wordpress, this is not relative to the header.php file, it’s relative to the index.php file in your web root!
With both scripts in place and the script reference added to your site template, you’re all set. Everything should be working. You can test it out by visiting your site and clicking any external link. If it opens in a new window, everything went well.
Using the code found in this article should help increase your page’s rank and search engine placement as well as allow pages with targeted links to validate under the new strict XHTML standards.