• My goal is to use the custom template functionality to customize an AMP experience separate from the primary site.

    However, the template files can not be duplicated into a custom template folder. I get this error: Uncaught Error: Using $this when not in object context in

    The template files provided in the plugin say specifically:
    You need to copy this file out of the plugin and put it into your custom theme.

    Are there boilerplate theme files I can customize from? Again, I have an existing template and theme. Changing to transitional mode simply causes the page to timeout. I’d like to build a separate AMP experience, starting from a clean boilerplate structure from inside my existing child theme.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @jasondavis You may be using a theme which already has amp support defined, which can result in that error. These themes work best in transitional or standard mode, as they use your themes styling and layout. If you are having issues with those modes I would suggest disabling some of the other plugins you have active temporarily, they could be the cause of the timing out problem.

    If you want to share your site we can take a look. You can also look in your themes functions.php file for any add_theme_support reference.

    You will find more information on reader mode customisation here, and how it works with themes.

    Thread Starter jasonhdavis

    (@jasonhdavis)

    @jamesosborne Thank you for the response. The theme is a heavily modified child theme of twentyseventeen and includes visual composer. My hope was to maintain a separate AMP template stored inside of the child theme.

    I setup a folder ‘amp-template’ and pointed to it using add_theme_support. The documentation says that this should be done with the Transitional method.

    Most of the pages work in Reader mode, except the homepage. None of the pages work in transitional, even with the plugin theme files copied over.

    You can see the site here: https://texastoilets.wpengine.com/

    The intention is to make custom amp landing pages for different marketing campaigns, so having a separate template and separate pages is not an issue.

    @jasonhdavis In that case using amp in transitional mode using custom templates may be your best approach. You can create your own templates using your Twenty Seventeen theme for use in amp only. As an example, from within your amp-template folder create a home.php file. You can copy the content from the Twenty Seventeens front-page.php. Modify to suit your needs and then view your homepage in amp.

    Using reader mode there is no home template, so unless your homepage is set to display a single page amp is not supported. The templates bundled with the plugin are not intended to be copied for use with amp theme support, but as you are using Twenty Seventeen you can copy whatever templates you like from that theme to use in AMP and modify to suit your landing pages or custom post types.

    Thread Starter jasonhdavis

    (@jasonhdavis)

    @jamesosborne Yes, I understand. So you’re saying that duplicating the twentysixteen files inside of the amp-template folder will be sufficient to act as a boilerplate theme?

    Again, please understand that I am not trying to build piecemeal, I want a boilerplate theme. Something that’s complete that I can then modify. So I will duplicate the entire twentysixteen theme, including static assets, and that will work?

    Besides front-page.php being changed to home.php, are there other files that will need filename changes?

    Also, you believe copying over the entire theme will resolve the timeout error that I am currently experiencing? Or would this be related to an installed plugin, such as Visual Composer?

    @jasonhdavis Apologies for the delay. You can start with index.php from your theme, copied to the amp-templates folder within your child theme, and making changes from there. A function like the below added to your themes functions.php should work:

    add_theme_support( 'amp', array(
    	'paired' => true,
    	'template_dir' => 'amp-templates',
    	'templates_supported' => 'all',
    ) );

    In relation to your timing out error it could be down to your page builder, or other plugin as you mention. Many page builders are not AMP compatible.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Boilerplate custom theme for transitional implementation’ is closed to new replies.