WordPress html5 validation – Bad value for attribute rel

A green for go amongst the red - photo by my buffo

If you want to get rid of the rel attributes that cause the html5 validation to fail.  There is some difference of opinion around this.

BUT,

  • your client may not understand – the site must be html5 AND valid!
  • I miss that green 100% valid reassurance when I am testing although I like to test with default wordpress and default theme… what to do?

If you want that green 100% valid response back, regardless, then……

Remove the rel attributes to get the green back

A bunch of actions and filters and yes,  you have to use a child theme with own header and footer unfortunately as some is hardcoded in the header.php

Add to child theme  functions.php or a temporary plugin:

remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head','adjacent_posts_rel_link_wp_head');
remove_action('wp_head','start_post_rel_link');

 

Theme edits

Footer.php

copy to child theme and edit footer.php

  • line 26 remove rel=”generator”

Header.php

copy to child theme and edit header.php

<link rel="profile" href="http://gmpg.org/xfn/11" />
  • line 74 remove rel=”home”

 

Another option: Replace rel attributes with accepted ones:

The links need a rel attribute, so choose a valid one and replace the invalid ones:

add_filter('parent_post_rel_link', 'amr_remove_rel_up');
 function amr_remove_rel_up($link) {
 return (str_replace ("rel='up'","rel='xxxxx'", $link));
 }
 add_filter('next_post_rel_link', 'amr_remove_rel_next');
 add_filter('prev_post_rel_link', 'amr_remove_rel_prev');
 add_filter('start_post_rel_link', 'amr_remove_rel_start');
 add_filter('end_post_rel_link', 'amr_remove_rel_end');
 add_filter('index_rel_link', 'amr_remove_rel_index');

etc.....

 

Published by

anmari

the developer at anmari