How To Create a Custom Post Template

Have you ever wanted to use a different template on a post? By default, most WordPress themes don’t normally offer a range of templates to choose from to use on different posts.

Pages however, are a different story and even the free Twenty Eleven default theme for WordPress offers 7 different ones to choose from.

Video On Creating Custom Post Templates

Using the default post template on all your blog posts is a bit boring so if you want to show you subscribers a different format for a particular reason then those templates can be copied over and used to create unique posts.

Depending on the theme you have installed, yours should also offer a range of different page templates which can be used on posts as well if you follow this little trick i have for you.

Caution: Its best practice to always create a full backup of your files & databases before making changes to your WordPress site.

Tools You Can Use

For this tutorial i’ll be using the page templates from the Canvas theme and File Manager in cPanel.

You could use any theme which offers a range of different page templates and also use FTP rather then File Manager if you wish.

I’ll also be using a child theme which you can create quickly and easily in cPanel using File Manager. This way your custom post templates will not be overwritten and lost when you update your theme.

Using a Plugin

Rather than playing around with php code, the easiest way to use your page templates on posts is to simply install the custom post template plugin.

Once you’ve installed the plugin by Simon Wheatley, you’ll find a module under your post tags in your Edit Post screen. Post TemplatesIts now time to create a post template by copying one of your existing page templates to your child themes folder.

Copy Page Templates

Using FTP or better still, File Manager in cPanel, copy the page templates you want to use for posts over to your child themes folder.

Navigate to wp-content/themes and inside you themes directory you’ll find your page templates.

Copy Page Template

Using File Manager, right click the ones you want to use as posts and copy them to your child themes directory

Child Theme Post Templates

Note: Page templates use different names than post templates so you’ll also need to edit the name at the top of each new post template file.

Edit File Names

Page templates use Template Name  whereas post templates use Template Name Posts so you’ll need to change this info at the top of each new post template.

To change this template name simple click Code Edit in File Manager and change Template Name to Template Name Posts

Template Name Change to Template Name Posts

You’ll now see your new custom templates in the drop down.

Custom Post Templates

Click the drop down to choose a new post template.

You can see from this screen shot that i’ve added 3 new templates.

Custom Single Post Templates

Note: You need to copy your themes index.php file into your child themes directory as well otherwise the post templates will not work. Be careful not to move the files but copy them to your child theme.

Comments

14 responses to “How To Create a Custom Post Template”

  1. Hi Brad
    I am trying to change the Posts page in AltitudePro.
    I am getting confused. Your instructions above are saying to copy page templates from wp-content/themes/my_theme to my_theme directory. Is this not the same place?

    On a posts page I seem to already have choice of templates (just not in a dropdown list)

    I am trying to either method working.

    1. Brad Dalton Avatar
      Brad Dalton

      Link to your posts page. Do you mean home page, front page or blog page?

      What do you want to change?

      1. I have made some more progress. I figured, I needed to rename the template file and update the name inside to include “Posts”. It seems that you can use either the standard templates, or the templates made available with the Custom Post Template plugin, but not both. The problem I have is if I use the Custom Post Template plugin to avail templates, I don’t get to add calendar and other widgets.
        I am talking about setting the template on the actual Post page.

        1. Brad Dalton Avatar
          Brad Dalton

          You can add widget areas to your template file.

          If you only want to usethe template on a small number of single posts, you can load it conditionally using template_include.

  2. hello Brad i am using a fast blog theme , and i never update my theme so is there a way to directly make a post template without having to make a child theme? Can you please help me with the steps ?

    1. Brad Dalton Avatar
      Brad Dalton

      Sure but you’ll never be able to update your parent theme.

      I would look in the Twenty Fourteen themes folder in the page-templates folder for examples

      1. oh i see. Can you please help me on how should i go on about it ? as the above tutorial explains with a child theme which is getting me confused. Thanks in advance.

          1. Thanks , ill try to work it out and see coz i am a total noob at all this , but ill work my way out somehow , hopefully.

          2. Brad Dalton Avatar
            Brad Dalton

            You’d find it easier to code using Genesis.

  3. Thanks for your great tutorial. I tried this out on twenty fourteen theme with fourteen extended plugin. I customized a full width post template, but the feature content post I used to try out this custom post template only shows without sidebar. The content does not extend to 100% full width. How can I make the post extended to full width? Do I need to modify the stylesheet?

    Here is the template:

    QUOTE

    <?php

    get_footer();

    UNQUOTE

    FYI, even though I have fourteen extended plugin, which can set all featured content posts to full-width once for all, I still keep all the featured content posts in content-sidebar format setting. Only I used one post to try out the custom post template.

    And I didn't use child theme. I placed the post template in the twenty fourteen theme folder.

    Your advice would be appreciated.

    mfan

    1. Brad Dalton Avatar
      Brad Dalton

      Please use your real name and an email address linked to your Gravatar and i will help you otherwise i will not help anyone who is anonymous. Thanks for your understanding.

  4. Marco Avatar

    Does this also work on productpages from WPEC from getshopped??
    greetz marco

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Marco

      Good question however You would need to be more specific. I always test these things out locally using different themes which is something you might want to try.

      I’m not very experienced with GetShopped and prefer to use WooCommerce or Easy Digital Downloads.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.