• Resolved ronaldlauweb

    (@ronaldlauweb)


    I’m using the Paired option.
    When I am in the AMP version, how can I do so all the items in my main menu point to the AMP URLs and not to the regular URLs?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Pascal Birchler

    (@swissspidy)

    Untested, but adding this to your theme or plugin should work:

    
    add_filter(
      'nav_menu_link_attributes',
      function( $atts ) {
        if ( isset( $atts['href'] ) && function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
          $atts['href'] = add_query_arg( amp_get_slug(), '', $atts['href'] );
        }
    
        return $atts;
      }
    );
    

    This will append ?amp to all the links in the menu if you’re on the AMP version of a page/post.

    Hope that helps!

    Thread Starter ronaldlauweb

    (@ronaldlauweb)

    It worked

    • This reply was modified 6 years, 1 month ago by ronaldlauweb.
    Plugin Author Weston Ruter

    (@westonruter)

    See also: https://github.com/ampproject/amp-wp/issues/1389

    There is a plugin there which will add ?amp to all site links on the page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘AMP URL redirect to the normal URL’ is closed to new replies.