Clicky

  1. Home
  2. Developer Docs
  3. Override Specific File
  4. Create Custom Template for post type and taxonomy in the AMP Theme Framework

Create Custom Template for post type and taxonomy in the AMP Theme Framework

An explanation for custom templating for developers. These template supports are available on:

Note: This Tutorial will work only with  AMP Theme Framework.

Here is the Structured of File:

Taxonomy: taxonomy.php
taxonomy-$taxonomy-{$slug_decoded}.php
taxonomy-$taxonomy-{$term->slug}.php
taxonomy-$taxonomy.php

Category: category.php
category-{$slug_decoded}.php
category-{$category->slug}.php
category-{$category->term_id}.php

Tag: tag.php
tag-{$slug_decoded}.php
tag-{$tag->slug}.php
tag-{$tag->term_id}.php

Archive: archive.php
archive-{$post_type}.php
Post type archive
archive-{$post_type}.php

Single: single.php
single-{$object->post_type}-{$name_decoded}.php
single-{$object->post_type}-{$object->post_name}.php
single-{$object->post_type}.php

Page: page.php
page-{$pagename_decoded}.php
page-{$pagename}.php
page-{$id}.php

Author: author.php
author-{$author->user_nicename}.php
author-{$author->ID}.php

archive-{post_type}.php
single-{post_type}.php

archive-{post_type}.php
If your custom post type were ‘product’, and/or query_var = “product”, AMP Framework would look for archive-product.php to display the archive of posts.

For more details check in WordPress template hierarchy

single-{post_type}.php
If your custom post type were ‘product’, and/or query_var = “product”, AMP Framework would look for single-product.php to display the single or permalink of the post.
Its Support single-{post_type}-{post_name_slug}, single-{$object->post_type}

For more details check in WordPress template hierarchy

For taxonomy also similar like: taxonomy-{taxonomy}-{slug}.php, taxonomy-{taxonomy}.php

Note:This might also work with design1, design2, design3  but it’s untested.

How to create a Custom Template for the custom post type

The following are the steps to create a Custom Template for the custom post type

Step 1:

Create a new file with the name “single-(custom post type slug).php” in your AMP theme Framework directory.

The directory will look like

ex:wp-content\plugins\amp-theme-framework

Single: single.php
single-{$object->post_type}.php

Step 2:

Once you create the file then in that file you need to do all the changes which you want and that customized file will appear for all your custom post types.

To make it easy, we have created a video also

How to create a Custom Template for custom taxonomy

The following are the steps to create a Custom Template for the custom taxonomy

Step 1:

Create a new file with the name “taxonomy-(custom post type slug).php” in your AMP theme Framework directory.

The directory will look like

ex:wp-content\plugins\amp-theme-framework

Taxonomy: taxonomy.php
taxonomy-$taxonomy.php

Step 2:

Once you create the file then in that file you need to do all the changes which you want and that customized file will appear for all your custom post types.

To make it easy, we have created a video also

How to create a Custom Page Template in AMP Theme Framework. 

If you are creating Custom Page Template for Non-AMP version then by default it will not work in AMP and for displaying in AMP you need to copy that custom file and paste it in your AMP Theme Framework directory

To make it easy, we have created a video also

That’s it for this tutorial!

We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.

Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on April 27, 2020

    Are you still looking for a solution?

    Then fill out the below form and we will reach out to you within a few hours.

    Was this article helpful?

    Related Articles

    Comments

    1. Hi.

      I have custom template for my HOME page. File “main.php”:

      test 111

      I copy this file (“main.php”) at the /wp-content/plugins/amp-theme-framework-master/ directory
      and modify it:

      test 222

      But it not working. I still see is used standart “page.php” as a template 🙁

    2. Hi

      I have created custom page template and its only work if we have switch off AMP pages but after that i got one video in which we need to add same template from theme to that plugin/amp-framework plugin and Just changed get_header to amp_header and same as for footer, after that have enable AMP for that page template and trying to access that page but not working. so is that creating new url for AMP ? If yes then how do we know ? I am newbie to AMP sorry for more questions.

      Thanks
      LR

    3. Hi, we have a custom theme built on our own, and AMP works fine for the posts, but not for the pages. Even putting the Template Name and adding a copy of the file in the plugin folder, the pages show empty (only header and footer are shown). I also added the support to amp in the functions.php. Is there something I may be missing in settings?

    Leave a Comment