Title: Custom template documentation
Last modified: September 4, 2019

---

# Custom template documentation

 *  Resolved [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/)
 * Hi again!
 * I’m struggling with custom template.
    There are a few questions I can’t find 
   info neither on the website documentation nor this support forum.
 * he thing is I’ve created custom amp template in “amp” folder in my current theme.
   
   Placed there some files from old default template, such as html-start.php, html-
   end.php, header-bar.php etc.
 * So I’ve got page.php and single.php too. I’ve added custom singular templates
   with the hook `amp_post_template_file`, no the questions are:
 * 1) How to set different template for pages with different templates.
    Default
   WP description `Template Name: Homepage Template` is not working.
 * 2) How to customize JS files list and add an `amp-carousel` to the template?
   
   I use custom html in the theme so there are carousels for certain templates with
   ACF.
 * 3) How to get amp-img from simple get_post_thumbnail() and etc.
 * Thanks.
    -  This topic was modified 6 years, 8 months ago by [Nikita_Sp](https://wordpress.org/support/users/nikitasp/).

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

 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11900208)
 * Have you considered Transitional mode? This allows you to re-use your active 
   theme’s templates in AMP, so you can do things as you do normally in WordPress
   themes. There is some documentation about that at [https://amp-wp.org/documentation/how-the-plugin-works/amp-plugin-serving-strategies/](https://amp-wp.org/documentation/how-the-plugin-works/amp-plugin-serving-strategies/)
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11900333)
 * [@westonruter](https://wordpress.org/support/users/westonruter/) thanks for fast
   reply.
 * Yeah, I was trying it, when I was testing different modes. And I saw a page without
   theme’s CSS, so I just turned “reader mode” back.
 * But now I tried again and some pages are working quite good and this mode seems
   cooler!
    Now I need to manage this issue with the styles. It’s interesting that
   there is no any logic in this issue.
 * Pages that has styles:
    – 1 archive (projects) with posts of this type – 2 pages
   with custom template – 1 simple page
 * Pages has NO styles:
    – Home page with custom template – 2 more archives with
   posts of this type – even simple post categories – and posts!
 * Maybe you have some suggestions?
    Thanks.
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11900340)
 * Also I see extra code on working pages that moves content down from top for about
   10-20px
 * `<amp-img height="1" width="1" src="https://www.facebook.com/tr?id=XXXXXXXXXXXXXXXXX&
   ev=PageView&noscript=1" class="amp-wp-enforced-sizes amp-wp-6a19fc1 i-amphtml-
   element i-amphtml-layout-intrinsic i-amphtml-layout-size-defined i-amphtml-layout"
   layout="intrinsic" i-amphtml-layout="intrinsic"><i-amphtml-sizer class="i-amphtml-
   sizer"><img alt="" role="presentation" aria-hidden="true" class="i-amphtml-intrinsic-
   sizer" src="data:image/svg+xml;charset=utf-8,<svg height=&quot;1px&quot; width
   =&quot;1px&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&
   quot;/>"></i-amphtml-sizer><noscript><img height="1" width="1" src="https://www.
   facebook.com/tr?id=XXXXXXXXXXXXX&ev=PageView&noscript=1" class="amp-wp-cb45893"
   ></noscript><img decoding="async" src="https://www.facebook.com/tr?id=XXXXXXXXXXXXXX&
   ev=PageView&noscript=1" class="i-amphtml-fill-content i-amphtml-replaced-content"
   ></amp-img>`
 * As I get I also need to turned off “Supported Templates” because it make my website
   AMP as default? (_This will allow all of the URLs on your site to be served as
   AMP by default._)
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11900583)
 * Interesting fact about Transitional mode.
    I’ve described behavior of pages (
   without css) on my lacalhost, but on web server (it’s locked with folder password?
   if it helps) all pages gives blank page.
 * Maybe better way is to show me how queue script to the reader mode template? 
   🙂
 * Thanks.
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11919779)
 * [@westonruter](https://wordpress.org/support/users/westonruter/) any ideas?
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11923256)
 * Sorry, this will probably need to wait until next week for a follow up.
 * /cc [@jamesosborne](https://wordpress.org/support/users/jamesosborne/)
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11931375)
 * [@nikitasp](https://wordpress.org/support/users/nikitasp/) Sorry for the delay.
   To add a script to the Reader mode templates, you can use code like this in your
   theme’s `functions.php`:
 *     ```
       add_filter(
       	'amp_post_template_data',
       	function( $data ) {
       		$data['amp_component_scripts'] = array_merge(
       			$data['amp_component_scripts'],
       			array(
       				'amp-carousel' => true,
       			)
       		);
       		return $data;
       	}
       );
       ```
   
 * This won’t be necessary once this is resolved: [https://github.com/ampproject/amp-wp/issues/2202](https://github.com/ampproject/amp-wp/issues/2202)
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11933878)
 * [@westonruter](https://wordpress.org/support/users/westonruter/) thank you!
    
   I will try this and give a response. Thanks.
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11936542)
 * [@westonruter](https://wordpress.org/support/users/westonruter/) thanks, all 
   works, except `amp-accordion`.
 * I have FAQ on pages and they wrapped by accordion. So I’ve added it to scripts,
   but nothing works…
 *     ```
       add_filter('amp_post_template_data', function($data){
       	$data['amp_component_scripts'] = array_merge(
       		$data['amp_component_scripts'],
       		array(
       			'amp-carousel' => true,
       			'amp-accordion' => true,
       		)
       	);
   
       	return $data;
       });
       ```
   
 * what’s wrong with merge?
 * Works only:
 *     ```
       add_filter('amp_post_template_data', function($data){
       	$data['amp_component_scripts'] = array_merge(
       		$data['amp_component_scripts'],
       		array(
       			'amp-carousel' => true,
       		)
       	);
   
       	$data['amp_component_scripts'] = array_merge(
       		$data['amp_component_scripts'],
       		array(
       			'amp-accordion' => true,
       		)
       	);
   
       	return $data;
       });
       ```
   
 * Thanks.
    -  This reply was modified 6 years, 8 months ago by [Nikita_Sp](https://wordpress.org/support/users/nikitasp/).
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11938091)
 * I’m not sure. Those should have the same exact result.
 *  Thread Starter [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11940710)
 * [@westonruter](https://wordpress.org/support/users/westonruter/) please, check
   that, because it’s not 🙂
    Anyway, seems the topic could be closed as we’ve got
   all the answers we’re looking for.
 * Thank you very much for your help!

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

The topic ‘Custom template documentation’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/custom-template-documentation/#post-11940710)
 * Status: resolved