• On class-amp-post.php file, function build_metadata shows as this:


    private function build_metadata() {
    $data = array(
    '@context' => 'https://schema.org',
    '@type' => 'BlogPosting', // TODO: change this for pages
    'mainEntityOfPage' => get_permalink( $this->ID ),
    'headline' => get_the_title( $this->ID ),
    'datePublished' => get_the_date( 'c', $this->ID ),
    'author' => array(
    '@type' => 'Person',
    'name' => $this->author->display_name,
    ),
    'publisher' => array(
    '@type' => 'Organization',
    'name' => get_bloginfo( 'name' ),
    ),
    );

    return $data;
    }

    But in order to show as valid AMP page on Google webmaster tools ( Section Search Appearance – Accelerated Mobile Pages) it has to show this fields too:

    logo: mising and it is required
    image: mising and it is required
    dateModified: mising and it is recommended

    Bests,
    Jose

    https://www.ads-software.com/plugins/amp/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Same problem here.

    Thread Starter ejos

    (@ejos)

    I solve the problem by changing the function build_metadata() on file plugins/amp/class-amp-post.php to:

    private function build_metadata() {
    
                    $data = array(
                            '@context' => 'https://schema.org',
                            '@type' => 'BlogPosting', // TODO: change this for pages
                            'mainEntityOfPage' => get_permalink( $this->ID ),
                            'headline' => get_the_title( $this->ID ),
                            'datePublished' => get_the_date( 'c', $this->ID ),
                            'dateModified'=> get_post_modified_time( 'c','' , $this->ID ),
                            'author' => array(
                                    '@type' => 'Person',
                                    'name' => $this->author->display_name,
                            ),
                            'image' => array(
                                            '@type' => 'ImageObject',
                                            'url' => get_the_post_thumbnail_url($this->ID),
                                            'width' => '696',
                                            'height' => '580',
    
                            ),
                            'publisher' => array(
                                    '@type' => 'Organization',
                                    'name' => get_bloginfo( 'name' ),
                                    'logo' => array(
                                            '@type' => 'ImageObject',
                                            'url' => 'https://url_to_my_logo.jpg',
                                            'width' => '187',
                                            'height' => '143',
                                    ),
                            ),
                    );
    
                    return $data;
            }

    Width and height values are my custom values you should change them with your own values.

    hope it helps

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘function build_metadata need more info in order to validate as amp page’ is closed to new replies.