• I am wondering how to include a new template in the AMP plugin for our 404 pages.

    I was thinking of checking an IF statement using is_404 and returning the correct custom template, but I am not really sure where I should place this.

    Please advise.

Viewing 15 replies - 1 through 15 (of 18 total)
  • @dereksmithweb What mode are you using the plugin with, would you be able to share your site?

    If you are using “Transitional” mode AMP then add the following to your functions.php file (if you theme does not already have AMP support):

    add_theme_support( 'amp', array(
    	'paired' => true,
    	'template_dir' => 'amp',
    ) );

    Then copy your 404.php page in your theme folder to a directory called “amp” in the same location. You can then edit that 404.php page inside the “amp” folder and it’s contents will only appear on AMP 404 error pages.

    Let me know if that works for you.

    • This reply was modified 5 years, 5 months ago by James Osborne.
    Thread Starter dereksmithweb

    (@dereksmithweb)

    Im using a customized version of it.
    In the option fields, there are no modes to select, only post types and unfortunately, updating is not an option.

    @dereksmithweb It sounds like you are using an older version of the plugin, meaning you are stuck on Classic mode. This mode does not support AMP 404 pages.

    If you manage to upgrade and change modes you can make use of custom types and templates.

    Thread Starter dereksmithweb

    (@dereksmithweb)

    I dont understand why I cannot use a 404 template in this version. Can you please elaborate? I thought that a condition check is_404() would be all I need to point the rendering onto a custom template.

    Thread Starter dereksmithweb

    (@dereksmithweb)

    My AMP settings show my custom post types aswell, but thats all I see, no type check (native etc).

    @dereksmithweb Can you tell me the theme & AMP plugin version you are using. Otherwise please share your URL and I will take a look. If you are using Classic mode then unfortunately 404 pages are not supported in via older versions of the AMP plugin.

    • This reply was modified 5 years, 5 months ago by James Osborne.
    Thread Starter dereksmithweb

    (@dereksmithweb)

    @jamesosborne first of all thanks for your prompt replies and your awesome support so far.

    Unfortunately, my theme is a custom one. I just updated it to the latest version preserving my custom templates.

    The mode is at classic!
    If i change to Transitional mode, amp view on single posts is a mess, my custom templates are ignored.

    Thread Starter dereksmithweb

    (@dereksmithweb)

    Can I have classic mode for posts and transitional for 404 ?

    @dereksmithweb It might take some work but creating or modifying your custom templates to suit transitional(paired) mode might be worth the effort. Along with having custom 404 pages you can have your category pages (alongside your homepage, which probably shows a list of posts) AMP. It will also ensure consistency between AMP and non AMP and you can use the validation feature to work through the errors for your AMP URLs.

    You can also make a lightweight templates in transitional mode using the function mentioned previously, so your content for AMP URLs look more appealing. I have even encountered some theme providers using classic templates via this method.

    Can I have classic mode for posts and transitional for 404 ?

    Unfortunately no, but I have encountered theme providers using ‘Classic’ templates in transitional mode. It’s not the most ideal scenario as their AMP URLs don’t look consistent with their non AMP. But if you are certain you want to use the classic template then it could be an option.

    • This reply was modified 5 years, 5 months ago by James Osborne.
    Thread Starter dereksmithweb

    (@dereksmithweb)

    Thanks again for your answer.

    So it seems that I need to stay in the classic mode and implement only a 404 page for this purpose, since rest of those valuable features (category etc) are outside of the scope of this website.

    Is there any chance to do this by staying at classic mode? Even if it involves lots of work, from your experience?

    @dereksmithweb As it’s not supported via the plugin it’s not something I have encountered or tried myself. But as mentioned you can use classic mode templates in Transitional(Paired) mode or work through the non AMP valid content via the validator to achieve a more consistent AMP experience using your theme.

    Thread Starter dereksmithweb

    (@dereksmithweb)

    I tried this mode, but moving my templates on the /amp/ folder returned posts with various errors.

    Seems like they need rewriting. Is this the case, from your experience onto a hybrid mode?

    There is rewriting involved if that’s the route you wish to take. From my experience the best scenario would be working through the AMP error index using the validator in transitional mode. If your AMP URLs look unsatisfactory (as you mention) you can place your chosen theme files in the amp folder, and then strip down or rewrite.

    Thread Starter dereksmithweb

    (@dereksmithweb)

    Since classic mode is not providing any issues to us, we would love to keep it.
    Moreover, we have eliminated all validation errors by hand.

    However, Im not sure in which file a rewrite should occur.
    Can you please elaborate?

    You can rewrite your copied theme files that are placed in the AMP folder to alter the appearance on AMP versions.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘is_404’ is closed to new replies.