PHP
  Home arrow PHP arrow Standards-compliant Link Targets with ...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Standards-compliant Link Targets with Wordpress
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-12-19

    Table of Contents:
  • Standards-compliant Link Targets with Wordpress
  • Dynamically adding rel=’no follow’
  • JavaScript link targets
  • Putting it all together

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    Standards-compliant Link Targets with Wordpress
    (Page 1 of 4 )

    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.

    I ran into an issue on one of my own Wordpress sites the other day, so I decided to share with you my solution.  What happened was I added an SEO modification to my site that finds all external links in my page and adds a rel=”nofollow” attribute to them.  However, I also like to target my external links to new windows, but the target attribute for the “a” tag has been depreciated and will not validate under XHTML strict.

    So I decided to combine a solution for both.  I wanted to create a PHP script that finds all links and checks the URL to see whether the destination is inbound or outbound.  If it is outbound, it adds a rel=”nofollow” attribute to the link.

    Once the page loads, a JavaScript scans for all outbound links and dynamically targets them to a new window.  This results in outbound links that open in new windows, while keeping the site both SEO friendly and standards compliant.

    For those who don’t understand the need for using the rel attribute on outbound links, this is a technique used by web masters to help preserve PageRank and increase search engine ranking.  I’ll try to explain this very briefly.

    Search engines rank pages based on a number of different criteria.  Two of these are inbound and outbound links.  As a web master, you can only control the second.  These outbound links are followed by the search engine spider, which determines how well they relate to your site.  The more closely related they are, the better your site will rank because the search engines have determined that this is more useful to end users.

    But imagine for a second that you are hosting a site about cooking and a user in your forums posts a link to a site about cars.  Now what?  A search engine robot is going to determine that this site is unrelated and may penalize your ranking!  Adding the rel attribute will instruct the robot not to, preventing any loss to your site.

    Now, this is certainly less of a concern if you do not have any publicly created content, but you’re certainly not out of the woods yet.  Perhaps you have an about page that links to your favorite band.  Or maybe you have a page that links to all of your clients.  All of these scenarios result in outbound links to sites that do not directly relate to your site’s main content.

    More PHP Articles
    More By Nilpo


     

       

    PHP ARTICLES

    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5
    - Working with Multiple Document Nodes with th...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway