• I would like to add itemprop=”description” to the meta tag description which is automatically generated by Yoast (trying to implement schema.org article markup). I’ve tried adding the following function:

    function infinity_meta_schema()
    {
    	if( class_exists( 'WPSEO_Frontend' ) )
    	{
    		global $wpseo_front;
    
    		$metadesc = $wpseo_front->metadesc( false );
    		echo '<meta itemprop="description" content="' . esc_attr( strip_tags( stripslashes( $metadesc ) ) ) . '" />' . "\n";
    	}
    }
    add_action( 'wpseo_head', 'infinity_meta_schema' );

    This generates the meta description I want, but there is also another meta description there without itemprop=”description”.
    How can I produce only one meta description with itemprop=”description” in it? How do I disable the default one?
    Any advice would be appreciate it. Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You may add

    itemprop="description"

    to /wp-content/plugins/wordpress-seo/frontend/class-frontend.php
    line 987

    If you realy want to but please notice, changes on plugins get lost on plugin updates!

    Thread Starter petra5

    (@petra5)

    Thank you ELExG for your reply. Yes, I guess that’s one option, but I would rather not mess with plugin files as everything would get overridden with the update.

    I don’t think there is an “easy” way to get this done, without messing with the plugin. sorry.
    But is itemprop=”description” so important?

    Thread Starter petra5

    (@petra5)

    Yes, I would like to implement itemprop=”description” so that we have better chances in appearing in in-depth articles search results. See the following from Google:
    https://support.google.com/webmasters/answer/3280182?hl=en

    Ok, thats interesting. Please let me know if you find a solution

    Thread Starter petra5

    (@petra5)

    I looked into class WPSEO_Frontend into a bit more details and we have function metadesc with an option not to echo the description. Here is top of the function:

    /**
    	 * Outputs the meta description element or returns the description text.
    	 *
    	 * @param bool $echo Whether or not to echo the description.
    	 *
    	 * @return string
    	 */
    	public function metadesc( $echo = true ) {
    		if ( get_query_var( 'paged' ) && get_query_var( 'paged' ) > 1 )
    			return;

    I tried adding the following code in the function above, but it still doesn’t work:
    $metadesc = $wpseo_front->metadesc( $echo = false );

    Any ideas anybody how to make this work?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WordPress SEO (Yoast) add itemprop="description" to meta description’ is closed to new replies.