Last active
March 15, 2016 20:54
-
-
Save pshapiro/2bbb4ad54d835db15e50 to your computer and use it in GitHub Desktop.
Fix Schema Validation for WordPress AMP Plugin where posts don't have a featured image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Edit AMP Plugin file: amp/includes/class-amp-post-template.php | |
/* | |
Change this bit of code to the below uncommented code: | |
$image_metadata = $this->get_post_image_metadata(); | |
if ( $image_metadata ) { | |
$metadata['image'] = $image_metadata; | |
} | |
$this->add_data_by_key( 'metadata', apply_filters( 'amp_post_template_metadata', $metadata, $this->post ) ); | |
} | |
*/ | |
$image_metadata = $this->get_post_image_metadata(); | |
if ( $image_metadata ) { | |
$metadata['image'] = $image_metadata; | |
} | |
if(empty($metadata['image'])){ | |
$metadata['image'] = array( | |
'@type' => 'ImageObject', | |
'url' => 'URL OF IMAGE', | |
'height' => 300, | |
'width' => 700, | |
); | |
} | |
$this->add_data_by_key( 'metadata', apply_filters( 'amp_post_template_metadata', $metadata, $this->post ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment