Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created May 12, 2017 23:21
Show Gist options
  • Save mjangda/31f49f9c613a664e3f62b3146e85b41d to your computer and use it in GitHub Desktop.
Save mjangda/31f49f9c613a664e3f62b3146e85b41d to your computer and use it in GitHub Desktop.
<?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