• I need help to force all the AMP links to always use “?amp=1” instead of “/amp”.

    I’m using for the filter below to accomplish it for <link rel=”amphtml”> in posts and pages (the code works) but in I’m homepage the <link rel=”amphtml”> and the link in the header of AMP pages the link uses “/amp”.

    I already saved the Permalinks but it doesen’t works.

    add_filter( 'amp_pre_get_permalink', 'my_amp_force_querystring_permalink', 10, 2 );
    
    function my_amp_force_querystring_permalink( $permalink, $post_id ) {
        return add_query_arg( AMP_QUERY_VAR, 1, get_permalink( $post_id ) );
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Hey @onigi

    Thank you so much for using the AMP plugin.

    Why do you want to force all AMP links to use “?amp=1” ?

    I need to understand the use case, so that we can provide better user experience.

    Regards,
    Ahmed

    Thread Starter onigi

    (@onigi)

    I’m in the same situation explained here:
    https://github.com/Automattic/amp-wp/issues/550
    using PrettyLink and lots of custom rewrites

    Permalink structure is: /%postname%%post_id%.html
    The /amp is not working, ?amp=1 works

    I need to force “AMP for WP – Accelerated Mobile Pages” to use ?amp=1 in the <link rel=”amphtml”> in homepage (I’m using “Homepage Support ON”)
    and in the Link in Header of AMP pages (otherwise I need to “Non-AMP HomePage link in Header and Logo ON” but I’d rather not)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Force url ?amp=1’ is closed to new replies.