WordPress Bad value category tag for attribute rel on element a

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.

Rating: 5.0/5. From 2 votes.
Please wait...
Jules

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

    No votes yet.
    Please wait...
    • Jules Jules says:

      Hi Ian,

      yes i know this 😉

      Thanks for your Feedback!

      Greets
      Jules

      No votes yet.
      Please wait...
  2. Anon Anon says:

    very helpful article , thanks 🙂

    No votes yet.
    Please wait...
  3. Strike Strike says:

    Thanks a lot for your help, it works ! 😀

    No votes yet.
    Please wait...
    • Jules Jules says:

      my pleasure. you are welcome 😉

      No votes yet.
      Please wait...
  4. Lionpath 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

    No votes yet.
    Please wait...
  5. Chris 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.

    No votes yet.
    Please wait...
    • Jules 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.

      No votes yet.
      Please wait...
  6. Sau Hi 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?

    No votes yet.
    Please wait...
    • Jules Jules says:

      Hi Sau Hi,

      just give it a try and you will see 😉

      No votes yet.
      Please wait...
  7. Bi0 Bi0 says:

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

    No votes yet.
    Please wait...
  8. mydeadpixel mydeadpixel says:

    Nice one mate!

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

    🙂

    No votes yet.
    Please wait...

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.