WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get the categories associated with a post in it's meta section by using the following code:

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

WordPress is generating the markup as:

<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>

This part rel="category tag" is making my code invalid. W3C validator throws an error saying:

Bad value category tag for attribute rel on element a: The string category is not a registered keyword or absolute URL. Whitespace in path component. Use %20 in place of spaces.

…w all posts in Uncategorized" rel="category tag">Uncategorized

Any idea how to rectify this?

share|improve this question
@toscho thanks for the edit. – Vikram Jan 1 '13 at 22:12
up vote 5 down vote accepted

Filter the_category, and remove those attributes:

add_filter( 'the_category', 't5_remove_cat_rel' );

function t5_remove_cat_rel( $list )
    return str_replace(
        array ( 'rel="category tag"', 'rel="category"' ), '', $list
share|improve this answer
any side effect of removing "rel"? – Tara Jan 1 '13 at 23:07
@t-p Yes, cleaner markup, better text-to-code-ratio. :) – toscho Jan 1 '13 at 23:13
thanks toscho, very useful snippet indeed! – Tara Jan 1 '13 at 23:23
I actually wrote a tutorial featuring similar code over a year ago. That tutorial can be found on my blog. – Joseph Leedy Jan 2 '13 at 4:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.