Skip to content

Instantly share code, notes, and snippets.

@felixarntz
Created November 6, 2013 12:26
Show Gist options
  • Save felixarntz/7335262 to your computer and use it in GitHub Desktop.
Save felixarntz/7335262 to your computer and use it in GitHub Desktop.
http://leaves-and-love.net/how-to-improve-wordpress-seo-with-schema-org/ (only works with WordPress SEO versions 1.7.1 and older!)
<?php
function yourtheme_meta_schema()
{
if( class_exists( 'WPSEO_Frontend' ) )
{
global $wpseo_front;
$canonical = $wpseo_front->canonical( false );
echo '<link itemprop="url" href="' . esc_url( $canonical, null, 'other' ) . '" />' . "\n";
$metadesc = $wpseo_front->metadesc( false );
echo '<meta itemprop="description" content="' . esc_attr( strip_tags( stripslashes( $metadesc ) ) ) . '" />' . "\n";
}
}
add_action( 'wp_head', 'yourtheme_meta_schema' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment