• Resolved Ashish Jangra

    (@ashishjangra-1)


    Hi

    I want to add non-amp url

    
    $current_url = amp_get_current_url();
    	
    	$nonAMPURL = amp_remove_endpoint( $current_url );
    	
    	
    	if ( $nonAMPURL ) { ?>
    	
    	<a class="view-non-amp" href="<?php echo  esc_url($nonAMPURL) ?>">View Non-AMP Version</a> <?php
    	}
    

    but it still print amp url.

    also can we rewrite ?amp to /amp.

Viewing 11 replies - 1 through 11 (of 11 total)
  • @ashishjangra-1 Are you using the plugin reader mode? If so you can add a link to your a non AMP URL following the steps from this previous support topic.

    Rather than using a shortcode you could also use the following:
    <?php printf( wp_get_canonical_url() ); ?>

    Plugin Author Weston Ruter

    (@westonruter)

    One addition is now needed to that, namely now that AMP-to-AMP linking is a thing.

    See https://github.com/ampproject/amp-wp/pull/4146

    In Reader mode this is not enabled by default, but for best results, you should add rel=noamphtml to the link.

    So you can do this:

    if ( function_exists( 'is_amp_endpoint' ) && ! is_amp_endpoint() ) {
        printf(
            '<a rel="noamphtml" href="%s">View Non-AMP Version</a>',
            esc_url( amp_remove_endpoint( amp_get_current_url() ) )
        );
    }
    Thread Starter Ashish Jangra

    (@ashishjangra-1)

    Hi

    Thanks for yous help, this fixed my error.

    In our wordpress site we have a static html page on our root directory so that can be access through site url like

    abc.com/static-page

    We have index.htm in static-page directory.

    So problem is amp is enabled on pages so this page also enabled for AMP view. But we don’t want to enable amp view for these static page. Can’t we add any meta tag for this kind of static pages.

    Thanks

    Plugin Author Weston Ruter

    (@westonruter)

    You can use the amp_to_amp_excluded_urls filter to do this. For example:

    add_filter(
    	'amp_to_amp_excluded_urls',
    	function ( $urls ) {
    		$urls[] = 'https://abc.com/static-page';
    		return $urls;
    	}
    );
    • This reply was modified 4 years, 7 months ago by Weston Ruter.
    • This reply was modified 4 years, 7 months ago by Weston Ruter.
    Thread Starter Ashish Jangra

    (@ashishjangra-1)

    How can we exclude all the links which is not belongs to blog under the blog content. for example, in blog we have some product page link so by default ?amp is added to the url but we don want as it creates redirect loops.

    Plugin Author Weston Ruter

    (@westonruter)

    Redirect loop? Wouldn’t the presence of ?amp just cause a redirect to remove ?amp?

    Thread Starter Ashish Jangra

    (@ashishjangra-1)

    I mean on amp blog detail page, we have internal links like our products etc so all those link have ?amp in at the end of their url. so when ever someone click on the link that takes you the target link with ?amp. now as we don’t enabled amp on our product page or any pages so it redirects you on non-amp page.

    So for that we have to pass non-amphtml rel in the link to avoid this, but we have 2k blog posts and have lots of internal link will be difficult to add manually.

    We have already added a filter on the_content to add rel attribute to the whole content but its not working.

    I hope this clears now.

    Plugin Author Weston Ruter

    (@westonruter)

    Ok, so to be clear: there is no issue with redirects happening in an infinite loop, correct?

    The only issue is that you are linking to the AMP version of a page but AMP is not available for it, so there is a single redirect from .../?amp to .../. Is that right? So while this redirect is not ideal, it’s not actually causing a big problem other than a bit more latency to navigate to the link, correct?

    Please share the code you are using to add the rel attribute to the links in your content.

    Please also share an example URL for an AMP page on your site that is incorrectly linking to the AMP version of a page for which AMP is not available.

    Hi,
    I have added one functionality (smart woocommerce search) in my some of my woocommerce page which will search that woocommerce products from that category Now I want to display that search functionality in non amp pages only and want to disable this search function for AMP.What to do that? How to exclude search function from AMP woocommerce page?

    Further, I have implemented Digits Popup for Login and Registration but that function is not working in AMP.Have there any way to make it AMP compatible or how to work in a way that Digits Popup will not functioning and impacting in case of AMP page.Any way to do that?
    Thanks

    @zotezo As per WordPress support forum guidelines please open your own support topics. I’ve responded to your other support topic in relation to this just now.

    With regards other plugins you will need to check with the plugin provider. If there is JavaScript output in the front end of your site the plugins may not work as expected in AMP (if plugin developers have not provided workarounds or made their plugins AMP compatible).

    Sorry I will maintain it.Thanks for notifying me..

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Non Amp URL’ is closed to new replies.