• The Knowledge Graph markup generated by the plugin is causing warnings when tested with Google Structured Data validation tool.

    I would like to suggest the following fix. In includes/json/knowledge-graph.php, modify the code around line 81 from this:

    
    if ( $type == 'Organization' ) {
    	$logo = esc_attr( stripslashes( schema_wp_get_option( 'logo' ) ) );
    } else {
    	$logo = '';
    }
    

    to this:

    
    if ( $type == 'Organization' ) {
    	$image_url = esc_attr( stripslashes( schema_wp_get_option( 'logo' ) ) );
    
    	if ( $image_url ) {
    		$logo = array(
        		"@type" 	=> "ImageObject",
        		"url" 		=> $image_url,
    		);
    	} else {
    		$logo = '';
    	}
    } else {
    	$logo = '';
    }
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Hesham Zebida

    (@hishaman)

    I am not sure what kind of warnings you are getting. But It seems to be working fine this way. Also Google suggest setting Logo with only a URL, that’s why it’s done this way in the plugin.

    On my tests; I don’t see any warnings in the Organization markup (see example test for schema.press site here).

    Also, have a look at Logo guidelines.

    Does the code snippet you’ve suggested clear the warning?

    I’m getting a similar error on a clients website.

    https://search.google.com/structured-data/testing-tool/u/0/?url=https://residentiallandlord.com/property-investment-wales-916/#url=https%3A%2F%2Fresidentiallandlord.com%2Fproperty-investment-wales-916%2F

    Its giving me the following error
    https://residentiallandlord.com/wp-content/uploads/2018/07/Residentiallandlord-schema.jpg (The attribute logo.itemtype has an invalid value.)”

    If I copy that section of code and run it as a code snippet on its own, it shows no error. If I copy the html and amend the code from

    <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Organization","url":"https:\/\/residentiallandlord.com\/","sameAs":["https:\/\/www.facebook.com\/residentiallandlord","https:\/\/plus.google.com\/+ResidentiallandlordCoUk-2002","https:\/\/twitter.com\/help4landlords"],"@id":"https:\/\/residentiallandlord.com\/#organization","name":"Residential Landlord","logo":"https:\/\/residentiallandlord.com\/wp-content\/uploads\/2018\/07\/Residentiallandlord-schema.jpg"}</script>

    to

    <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Organization","url":"https:\/\/residentiallandlord.com\/","sameAs":["https:\/\/www.facebook.com\/residentiallandlord","https:\/\/plus.google.com\/+ResidentiallandlordCoUk-2002","https:\/\/twitter.com\/help4landlords"],"@id":"https:\/\/residentiallandlord.com\/#organization","name":"Residential Landlord","logo":{"@type":"ImageObject","url":"https:\/\/residentiallandlord.com\/wp-content\/uploads\/2018\/07\/Residentiallandlord-schema.jpg","width":600,"height":60}}</script>
    It resolves the issue.

    How do I amend this in the plugin, would the code suggested above do this? as I have over 2000 pages with the same warning

    • This reply was modified 7 years, 9 months ago by solarblitz77.
    • This reply was modified 7 years, 9 months ago by solarblitz77.
    • This reply was modified 7 years, 9 months ago by solarblitz77.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Knowledge Graph markup causing Structured Data validation warning’ is closed to new replies.