get_the_category_list produces rel attribute with invalid values
-
In the file “wp-includes/category-template.php”, in the function called get_the_category_list()
There are links produced, for category linkage in the content template, which have a rel attribute, which has values that are invalid.
On my blog the links suffer this failure on validation:
Bad value category tag for attribute rel on element a: Keyword category is not registered.
Apparently it’s trying to put “category” in the rel attribute which is not supported by W3C standards.
https://dev.w3.org/html5/spec/Overview.html#linkTypes
To fix the validity, of the content produced by wordpress, I would like to make the following suggestions:
A.
Change This line (in wp-includes/category-template.php):
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
The current code appears to be saying, if using rewrite and if using permalinks, list it as a category and tag, otherwise just a tag.
This is an incorrect semantic use of these rel tags as described by W3C. According to official html5 specification, the tag link is as follows:
“Gives a tag (identified by the given address) that applies to the current document.”
In the context of wordpress, this would be applicable to both tag and category links.
Since there is no such thing as a “category” link type, use rel=”tag” for both category and tag links. I suggest using the “bookmark” type for indicating a permalink; which would be more appropriate in this situation:
“Gives the permalink for the nearest ancestor section.”
A more semantically correct line to produce the rel attribute would be this:
To this:
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="bookmark tag"' : 'rel="tag"';
I think this will achieve the desired effect of the rel attribute in this context. “tag” is appropriate regardless of using permalinks because tag describes a relationship to application content. This is something that category and tag links both do in the wordpress context. “bookmark” is indicative of a permalink and so it is appropriate in the true condition of this clause.
B:
This may be a better option than all of the above:
Just let the template creators define this attribute in their templates. Give a good example of how to do it in twenty(twelve?), and otherwise give content producers the ability to sculpt their links as they please.
- The topic ‘get_the_category_list produces rel attribute with invalid values’ is closed to new replies.