WordPress generates invalid markup, how to remove it?

Hey. I am trying to get the categories associated with a post in a meta section using the following code:

<div>FILED AS: <span class="gf-post-meta-result"><?php the_category(' &bull; ') ?></span></div> 

WordPress generates markup like:

 <div>FILED AS: <span class="gf-post-meta-result"><a href="http://localhost/test/category/uncategorized/" title="View all posts in Uncategorized" rel="category tag">Uncategorized</a></span></div> 

Problem:

This part of rel="category tag" generated by wordpress makes my code invalid. W3c Validator gives an error message:

The rel attribute bad value category tag for element a: the category of strings is not a registered keyword or an absolute URL. Space in the path component. Use% 20 instead of spaces.

 …w all posts in Uncategorized" rel="category tag">Uncategorized</a></span></div> 

Any idea how to fix this?

+4
source share
2 answers

Just paste the following code into your functions.php file inside the theme folder

 function remove_category_rel($output) { $output = str_replace(' rel="category tag"', '', $output); return $output; } add_filter('the_category', 'remove_category_rel'); 
+3
source

These two rel values ​​are not valid. The validator is not updated.

Therefore, it makes no sense to use these values. The validator is likely to catch up in the future.

+5
source

All Articles