Quick fix for rel=”category tag” in WordPress

Here is a quick tip for helping WordPress, WordPress 3.2 specifically, with the HTML5 spec. HTML5 spec says that only certain rel types are allowed and WordPress’ “category tag” isn’t one of them. Fortunately I found a good bit of code here http://smalldiary.com/wordpresshow-to-add-nofollow-to-category-links.html which strips out the current rel=”category tag” and adds a rel=”nofollow” as a filter in the fuctions.php file for the theme. By adding it to the functions.php for the theme this provides a theme wide fix rather than having to edit individual templates.

I altered the code a bit for my uses, however, as I’d still like the search engines crawling around my site so I stripped the code down to:
add_filter( 'the_category', 'add_nofollow_cat' );  function add_nofollow_cat( $text ) { $text = str_replace('rel="category tag"', "", $text); return $text; }
Now the W3 Validator has one less WordPress quirk to pickup on.

24 responses to “Quick fix for rel=”category tag” in WordPress”

  1. […] soluzione l’ho trovata in questo articolo […]

  2. Bhushan Avatar
    Bhushan

    Will you please assist me exactly where i keep this code in function.php file

Leave a Reply

Your email address will not be published. Required fields are marked *