• Resolved thejazzpiper

    (@thejazzpiper)


    Hi,

    I am trying to add URL to author schema for AMP, doesnt seems to work on AMP template overwriting the metadata, help pls?

    $metadata['author'] = array(
            '@type' => 'Person',
            'name' => esc_html( get_the_author_meta( 'display_name', $post->ID ) ),
            "url"  => esc_url( get_author_posts_url( get_the_author_meta( 'ID', $post->ID ) ) )
        );
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thanks for reaching out. Rather than using a filter you could create an amp folder within your active themes root directory. Within that folder you can then insert any of the legacy themes templates and modify them to suit your needs.

    In your case you can insert a copy of the meta-author.php file within the amp folder and use “get_author_posts_url” to add a link.

    The full modified template should look similar to the below:

    $post_author = $this->get( 'post_author' );
    ?>
    <?php if ( $post_author ) : ?>
    	<div class="amp-wp-meta amp-wp-byline">
    		<a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
    		<?php if ( function_exists( 'get_avatar_url' ) ) : ?>
    	
    			<amp-img src="<?php echo esc_url( get_avatar_url( $post_author->user_email, [ 'size' => 24 ] ) ); ?>" alt="<?php echo esc_attr( $post_author->display_name ); ?>" width="24" height="24" layout="fixed"></amp-img>
    
    		<?php endif; ?>
    		<span class="amp-wp-author author vcard"><?php echo esc_html( $post_author->display_name ); ?></span>
    		</a>
    	</div>
    	
    <?php endif; ?>

    Let me know if you need any further assistance with the above.

    @thejazzpiper As we haven’t received a response, I’ll mark this as resolved. Feel free to open a new support topic if you continue to encounter issues, or reopen this topic and we’d be happy to assist. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding URL to Post Author Schema’ is closed to new replies.