• Resolved alexleonard

    (@alexleonard)


    Hi there,

    I’m just in the process of finalising my site and want to use Google’s meta tags for customising the +Snippet in a +1 share.

    <meta itemprop="name" content="Title of your content">
    <meta itemprop="description" content="This would be a description of the content your users are sharing">

    I can populate the first field just using

    <meta itemprop="name" content="<?php wp_title(); ?>">

    However, I would like to access the WordPress SEO generated description to populate the second meta element.

    Is there a template tag I can use, or some other way to get this information?

    Cheers for the awesome plugin!
    Alex

    http://wordpress.org/extend/plugins/wordpress-seo/

Viewing 1 replies (of 1 total)
  • Thread Starter alexleonard

    (@alexleonard)

    Ok, I’ve worked this one out.

    I’ve got the following code in my head to prepare the correct itemprop items as per Google+ requirements.

    <!-- Add the following three tags inside head -->
    	<meta itemprop="name" content="<?php wp_title(); ?>">
    	<?php
    		$postCustom = get_post_custom($post->ID);
    		$yoastMetaDescription = $postCustom['_yoast_wpseo_metadesc'][0];
    		if ($yoastMetaDescription) {
    			echo '<meta itemprop="description" content="' . $yoastMetaDescription . '">' . "\n";
    		}
    	?>
    	<?php
    		if ( has_post_thumbnail($post->ID) ) {
    			$featuredThumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'standard-list-thumb');
    			echo '<meta itemprop="image" content="' . $featuredThumb[0] . '">';
    		}
    	?>

    I’m using ‘standard-list-thumb’ as my image size, but you’ll need to replace it as you see fit.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Template tag or similar to get WordPress SEO Description’ is closed to new replies.