Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
add_filter( 'rest_prepare_post', 'amp_add_amphtml_link_to_rest_response', 10, 2 );
function amp_add_link_to_rest_response( $response, $post ) {
if ( ! post_supports_amp( $post ) ) {
return $response;
}
$response->add_link( 'amphtml', amp_get_permalink( $post->ID ) );
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment