• Resolved shalomgabay

    (@shalomgabay)


    Hey !
    currently, I’m using the classic mode for only my news single post types and I’m overriding any page template that I need from my child theme.

    I was wondering what will be the difference and the effort that I will need to switch into the Transitional mode.
    Will I still have the ability to use the AMP files that I’m overriding inside my theme?

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    The difference is that in Transitional mode you’ll be able to use the exact same template in AMP as non-AMP. Also, you’ll be able to write theme templates the normal way in WordPress. You can still override templates for AMP responses, however. To do that, you’ll need to specify a template_dir.

    For example, if you want to serve a different single.php in AMP than non-AMP, you can create a directory like amp-templates in your theme and then put a single.php inside of it; you then tell the plugin about this directory via adding this to your theme’s functions.php:

    add_theme_support( 'amp', array(
    	'template_dir' => 'amp-templates',
    ) );

    For more on this, see https://amp-wp.org/documentation/how-the-plugin-works/amp-plugin-serving-strategies/

    Nevertheless, it is better to not override the template if you can help it. The AMP version should ideally be the same as the non-AMP version. If you need to have two separate template partials in the template for AMP vs non-AMP, you can use the is_amp_endpoint() function in the theme’s regular template file to check if it is rendering an AMP page or not. For example:

    if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
        // Put AMP code here.
    } else {
        // Put non-AMP code here.
    }

    In this way, you don’t need to create an entirely separate template file.

    Thread Starter shalomgabay

    (@shalomgabay)

    Thanks Weston!
    I just wanted to say how much I appreciate your detailed answers, they are super helpful, So Thanks!

    Few small clarifications –
    the function – is_amp_endpoint() canot use also in the classic mode right?

    and btw – do you have any option within the plugin that helps somehow implement custom-scripts support?

    Plugin Author Weston Ruter

    (@westonruter)

    Few small clarifications –
    the function – is_amp_endpoint() canot use also in the classic mode right?

    This is not relevant in Reader mode (formerly Classic) because in Reader mode dedicated AMP templates are used, distinct from non-AMP templates. It is only relevant in Standard/Transitional modes where templates are shared between AMP and non-AMP.

    and btw – do you have any option within the plugin that helps somehow implement custom-scripts support?

    I don’t understand. What custom scripts specifically? To do what?

    Thread Starter shalomgabay

    (@shalomgabay)

    Thanks.
    basically I’m trying to add my custom scripts logics and i know it’s a tough task with amp and i was wondering if there is any pre implement CDN through the plugin.

    not an important issue, thanks again.

    Plugin Author Weston Ruter

    (@westonruter)

    What specific functionality are you wanting custom scripts for?

    Thread Starter shalomgabay

    (@shalomgabay)

    for now just a basics click events and stuff like that.
    import google \ facebook pixels and other services

    Plugin Author Weston Ruter

    (@westonruter)

    You should be looking at using AMP components instead of writing custom scripts for such functionality: https://amp.dev/documentation/components/

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Switch From Classic to Transitional’ is closed to new replies.