• Resolved JohnDBB

    (@johndbb)


    Hello,

    We have a big problem as AMP disables itself when we change the post template and the we save as a draft.

    Is there anyway to prevent the AMP plugin from disabling itself?

    Thank you in advance

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

    (@westonruter)

    Is the plugin disabling itself or just AMP being disabled for that one post? You may just need to make sure that AMP is enabled for that one post after selecting the post template. In Reader mode, the plugin disables AMP by default for a post when a template is selected, since this template won’t be used on AMP pages.

    You can find the AMP enabled toggle in the panel where you control the post’s date.

    Thread Starter JohnDBB

    (@johndbb)

    Than you for your prompt answer!

    AMP is disabled for that one post. The secuence is:
    – AMP is enabled when the post is created. The user starts creating the post.
    – The user changes the post template for that particular post. AMP is still enabled.
    – The user saves the draft post. Then AMP is suddenly disabled. It only happens if previously the user have changed from the default template to a different one.

    This is a newspaper with many users writing posts and that behaviour only generates posts without AMP version.

    Is there anyway to avoid this, or to force AMP to be always active?

    Thank you in advance!

    Best,

    • This reply was modified 3 years, 10 months ago by JohnDBB.
    Plugin Author Weston Ruter

    (@westonruter)

    Yes, you can use this PHP plugin code:

    add_filter( 'amp_post_status_default_enabled', '__return_true' );

    You can put that in a custom plugin. (It’s not recommended to put it in your theme’s functions.php.)

    You can see the source code for the underlying logic that is used to decide whether AMP is enabled by default for a post here: https://github.com/ampproject/amp-wp/blob/d9add694d4f5bb7a3cf0532bb4c580cbae24c68b/includes/class-amp-post-type-support.php#L150-L190

    The ! (bool) get_page_template_slug( $post ) part in the condition is what you’re dealing with.

    Thread Starter JohnDBB

    (@johndbb)

    Ok, thanks a lot for your support!!

    Plugin Author Weston Ruter

    (@westonruter)

    We’d appreciate a plugin review if you get a chance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘AMP disables itself after changing post template’ is closed to new replies.