Support » Plugin: AMP » Reader mode – allow AMP to work on post different templates

  • Resolved tomfromto

    (@tomfromto)


    Hello,

    I’m using the WordPress plugin and I’ve set AMP in the reader mode to use our posts and a couple of custom post types. AMP activates on our default post template (just a regular blog post), however if we set a post to use a post template other than default, AMP doesn’t activate. To be clear we’ve made this post template in our code using the standard wordpress naming of:

    Template Name: Text Post
    Template Post Type: Post

    In summary, how do we instruct AMP to also activate on ‘text post’ template post? We do not wish to use the transitional or standard setting for the plugin. Is there a function/hook we can call to allow different post templates?

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

    (@westonruter)

    Because Reader mode templates are distinct from the templates being used on your site. When you select a custom template for a page/post, the AMP plugin defaults to not enabling AMP for that post because the template you selected will not be reflected in the AMP version. In order to force the AMP plugin to go ahead and enable AMP for posts with custom templates assigned, all you need to do is toggle “Enable AMP” for that post. You can find this in the standard “Status & Visibility” section of the edit post screen.

    Alternatively, if you want to do this automatically then you can add this code to your custom theme’s functions.php or a custom plugin:

    add_filter( 'amp_post_status_default_enabled', '__return_true' );

    For more information, please refer to the full logic in AMP_Post_Type_Support::get_support_errors(): https://github.com/ampproject/amp-wp/blob/4a45440d1bfd91735152805e6c88816a0acd6053/includes/class-amp-post-type-support.php#L110-L145

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.