Oct
25
2012

Remove REL in WordPress Category Links for HTML 5 Validation

By Gabriel Harper Posted in

WordPress has a handy little function called the_category() which outputs a link to the current post category in the loop. Unfortunately it adds a rel tag that breaks HTML5 validation. Here’s a quick fix for your theme’s functions.php.

To stop WordPress from adding rel="category tag" to your category links, just edit your theme’s functions.php file and add the following code:

1
2
3
4
5
add_filter('the_category', 'remove_category_rel');
function remove_category_rel($string)
{
    return str_replace('rel="category tag"', '', $string);
}

The above function just replaces the rel attribute with… nothing. Proceed with HTML5 validation.

About The Author

Gabriel Harper

Gabe is the owner and founder of Intavant, and contributes to Intavant Blog regularly with his expertise in design, development & business.

Did you find this article helpful? Please subscribe!