• In Transitional mode a lot of my theme’s functionality doesn’t seem to work, including the drop-down menu and other things.

    I tried reader mode and it seems to look ok for my purposes. I only need amp for the SEO benefits.

    In reader mode some of my plugins(shortcodes) still are not working because they depend on JS, example my slider plugin(Master Slider), so I want to create some fallbacks, other than checking the URL for the ?amp query in PHP, is there a special constant or function I can use to know if the user is currently viewing the amp version of a post?

    The other question I have is how do I go about editing the default reader template? By Edit I mean maybe duplicate it and change some things about it such as the color of the top bar and some standard formating things

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can use a condition such as the below:

    <?php if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) : ?>
        ...amp code here...
    <?php else : ?>
        ...non amp code here...
    <?php endif; ?>

    You can also use this plugin to display content via a shortcode based on an AMP URL or non.

    As you are using the plugin reader mode you can also use the amp_post_template_data filter in your functions.php.

    In relation to modifying the reader mode templates you can do so by copying over any of the reader mode templates and placing them in your active themes directory within a folder called amp. Any of the templates in this newly created amp folder will overwrite the plugins reader mode templates.

    Thread Starter Uriahs Victor

    (@uriahs-victor)

    I used this guide for filtering shortcodes and it works perfect: https://make.xwp.co/2016/08/26/integrating-amp-into-wordpress-a-comprehensive-guide/#filtering-shortcodes

    What I plan to do is wherever a Masterslider shortcode occurs in the content, I will replace it with some text saying something like

    “To view this slideshow please click here to view full blog post.” The link would go to the non-amp blog post.

    As I said I mostly want to use AMP for the SEO benefits since google is pushing AMP posts so hard. But I have several articles with Masterslider shortcodes already.

    So I’m wondering if having such a replacement note inside my posts whenever certain shortcodes are not supported for amp, would be a violation of any amp policy or something?

    @uriahs-victor Nice article. The shortcodes in the mentioned plugin don’t violate any AMP principles. It’s no problem to place that notice you specific for your AMP content in either the condition or the plugin.

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

The topic ‘Detect AMP, Edit Default reader template’ is closed to new replies.