Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Last active March 15, 2019 21:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GaryJones/765627471d1cb457ebeb2e0cc31a235d to your computer and use it in GitHub Desktop.
Save GaryJones/765627471d1cb457ebeb2e0cc31a235d to your computer and use it in GitHub Desktop.
Genesis: Remove microdata attributes
<?php
// Copy everything below this line in to your functions.php file.
/**
* Remove microdata attributes from Genesis 2.6.0.
*
* May need adapting for other versions of Genesis.
*
* @author Gary Jones, Gamajo.
* @link https://gist.github.com/GaryJones/765627471d1cb457ebeb2e0cc31a235d
*/
function gmj_remove_genesis_microdata() {
$contexts = [
'head',
'body',
'site-header',
'site-title',
'site-description',
'breadcrumb',
'breadcrumb-link-wrap',
'search-form',
'nav-primary',
'nav-secondary',
'nav-header',
'nav-link-wrap',
'nav-link',
'entry',
'entry-image',
'entry-image-widget',
'entry-image-grid-loop',
'entry-author',
'entry-author-link',
'entry-author-name',
'entry-time',
'entry-modified-time',
'entry-title',
'entry-content',
'comment',
'comment-author',
'comment-author-link',
'comment-time',
'comment-time-link',
'comment-comment',
'author-box',
'sidebar-primary',
'sidebar-secondary',
'site-footer',
];
$microdata_attributes = [
'itemscope',
'itemtype',
'itemprop',
];
foreach ( $contexts as $context ) {
add_filter( 'genesis_attr_' . $context, function( array $attributes ) use ( $microdata_attributes ) {
foreach ( $microdata_attributes as $att ) {
unset( $attributes[ $att ] );
}
return $attributes;
});
}
remove_action( 'wp_head', 'genesis_meta_name' );
remove_action( 'wp_head', 'genesis_meta_url' );
}
gmj_remove_genesis_microdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment