@keshabee Thanks for the suggestion. The plugin is intended achieve AMP valid status using existing WordPress themes where possible, without adding any additional markup. You could always apply a link using a function similar to the below:
function add_amphref_link($content){
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
return $content;
}else{
global $wp;
$content .= '<a href="'.amp_get_permalink( get_queried_object_id()).'">View AMP version</a>' ;
return $content;
}}
add_filter( "the_content", "add_amphref_link" );
Most visitors to your site probably arrive on an AMP URL when discovered via search from mobile, as opposed to manually adding the /ampor /?amp suffix. Search engines have various factors that determine what version of a site is served if using the plugin in reader or transitional mode.
@jamesosborne Thank you for your quick response and detailed note.
The code was so helpful, but I wanted to ask if there was a method to make the “View AMP version” show only on the post.
On the Supported Templates: I selected The following content types post and media to be available as AMP:
As I noticed, the link “View AMP version” kept on showing up in areas of pages and buddy-press profile.
Which was odd because I was hoping it would only be displayed in the post
Hope to hear from you soon.
Thank you