WordPress Bad value category tag for attribute rel on element a

Updated August 2026: Invalid rel values on category/tag links were an HTML5 validation issue in older themes/plugins. If you still see “Bad value … for attribute rel”, inspect the theme or a SEO plugin’s breadcrumb/link output and remove non-standard rel tokens. Core WordPress is fine here.

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.

You may also like...

12 Responses

  1. Perfect!
    Many thanks for sharing i hate when my site does not validate and this tip has saved me a lot of time.
    All the best,
    Ian

  2. Anon says:

    very helpful article , thanks 🙂

  3. Strike says:

    Thanks a lot for your help, it works ! 😀

  4. Lionpath says:

    Thanks a lot.
    Works well. Now we only need to convince the WordPress team to fix the source of the problem, so we don’t have to re-apply the fix on each update.
    Cheers

  5. Chris says:

    Just remember that there is no actual need to do this as the category tag is a valid link type extension (see here for a full list: http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions). The W3C validator is probably not up to date, but they will fix this soon I guess.

    • Jules says:

      Hi Chris,

      Yes that might be true. I agree with this. But until it hasn’t fixed, this is the solution to fix the error message in w3c, if you intend to get a successful site validation for w3c validation banners e.g.

  6. Sau Hi says:

    I used W3C HTML validation to validate my site, I got 1 warning but do not know how to fix it. Please help me.

    Does WordPress fix this error in WP 3.6?

  7. Bi0 says:

    Many thanks for your advice! It works! 🙂 I’m glad that I’ve found your article on Google.

  8. mydeadpixel says:

    Nice one mate!

    I’ve got the w3c validation Nazi’s on my back and this sorted it right out!!

    🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.