Vous souhaitez faire votre geste écologique* du jour et par la même occasion faire plaisir à Google, parce que je reste persuadé qu’un de ces critères est la propreté du code, alors nettoyez la balise head de votre WordPress
Quelles sont les balises inutiles ?
La liste n’est pas exhaustive :
- meta generator
- link rel=’index’
- link rel=’shortlink’
- link rel=’prev’ et rel=’next’ (celles là sont maintenant pris en compte par Google mais des fois donne accès à des pages qu’on ne souhaite pas divulguer)
Comment enlever proprement ces balises ?
Tout simplement grâce à la commande : remove_action( ‘wp_head‘, ‘balise’ );
Rendez-vous dans votre thème, puis dans le fichier functions.php
A la fin du fichier vous pouvez ajouter autant de remove_action que vous voulez.
Pour info voici le code que j’utilise régulièrement :
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 );
remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator' );
Il me semble l’avoir trouvé à l’époque ici : http://wpengineer.com/1438/wordpress-header/
Bon nettoyage.
*écologique car moins de code dans votre page = moins de données à transférer = moins d’énergie consommée
Merci pour l’astuce, je cherchais une méthode propre pour enlever ces fameuses balises.