Categories: SolutionsWordpress

WordPress Bad value category tag for attribute rel on element a

WordPress Bad value category tag for attribute rel on element a

The W3C Validator showing you this error in? WordPress Bad value category tag for attribute rel on element a The string category is not a registered keyword

For whatever reason they didn’t fix this yet, since i still got this error on the latest WordPress 3.5 release.

 

 

There are two workarounds for this. Second one is the better choice!

The first one is by editing file wp-includes/category-template.php

This is exactly what we are doing now:

Goto line 163 in your category template (wp-includes/category-template.php) file:

$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->;using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';

and remove the category include whitespace, so that the line looks like this now:

$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->;using_permalinks() ) ? 'rel="tag"' : 'rel="category"';

We have now a W3 conform rel value in our code and the error should be gone.

Remember: Every time you update your Blog to a newer Revision you have to redo this step again, since the file is getting overwritten.

The second and more cleaner and persistent workaround would be a filter set you put in functions.php within your themes directory.

function ispireme_fix_category_tag ($ispireme_cat_output) {
$ispireme_cat_output = str_replace(array('rel="category tag"','rel="category"'),'', $ispireme_cat_output);

return $ispireme_cat_output;
}
add_filter( 'the_category', 'ispireme_fix_category_tag' );

This filter set would be your first choice since you don’t have to modify your category-template.php on every wordpress upgrade.

Jules

Jules is the owner and author of ISPIRE.ME. He's a Linux System Engineer, Tech fanatic and an Open Source fan.

View Comments

Share
Published by
Jules

Recent Posts

HTTP/2 SSL Offloading with Hitch and Varnish

HTTP/2 SSL Offloading with Hitch and Varnish Since Chrome browsers showing you insecure warning on…

7 years ago

File changed as we read it GlusterFS issue

File changed as we read it GlusterFS issue Recently i had trouble running Backups of…

8 years ago

Running multiple instances of varnish using systemd

Running multiple instances of varnish using systemd If you have not yet found a complete…

8 years ago

HTTP/2 SSL Offloading with Haproxy and Nginx

HTTP/2 SSL Offloading with Haproxy and Nginx After HTTP/2 becoming more an more prominent regarding SSL…

8 years ago

Get Real IP with Haproxy Tomcat Jira Confluence using x-forwarded-for

Get Real IP with Haproxy Tomcat Jira Confluence using x-forwarded-for Everyone knows the Problem. Get…

8 years ago

Review TDS2 How to backtest using tick data with Metatrader 4

Review TDS2 How to backtest using tick data with Metatrader 4 in this Review TDS2…

8 years ago

This website uses cookies.