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.
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
Hi Ian,
yes i know this 😉
Thanks for your Feedback!
Greets
Jules
very helpful article , thanks 🙂
Thanks a lot for your help, it works ! 😀
my pleasure. you are welcome 😉
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
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.
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.
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?
Hi Sau Hi,
just give it a try and you will see 😉
Many thanks for your advice! It works! 🙂 I’m glad that I’ve found your article on Google.
Nice one mate!
I’ve got the w3c validation Nazi’s on my back and this sorted it right out!!
🙂