Home WordPress How to Create Custom Post Template in WordPress

How to Create Custom Post Template in WordPress

If you have been so long creating with WordPress, then you must be know that there are two type of posts in WordPress. There are page and post it self. Post can be used to create common article like we used to do while page is tend to be suitable for creating any specific page like about page, contact page and more.

If you ever noticed, there is bit different between the two. When you are writing an article in the post mode, you will see no template option. Your article will be published in the default way offered by your theme.

Meanwhile, when you are creating an article for a specific page in the page mode, there will be some template options to customize the look of your page. For example, you may want your article be published in a full width without sidebar. To make it clearer, lets the image below.

For a specific reason you may want to create a custom template for your exclusive post (in the post mode). If so, this article will show you how. To get this tutorial work, you need to install a plug in called Single Post Template. Then follow these instructions.

We assume that you have installed the Single Post Template plugin so we will skip this step.

Step one: creating a php file for your custom template

Once you done installing the Single Post Template plugin, you need to create a php file. This file will be used for your custom template. You can name this file anything you want. In this example we will name it customsingle.php. Don’t worry about the content of this file. You can copy the codes from your normal single.php of your template. Put this new file on your theme directory.

Step two: add a special comment on your new file

You can edit anything on your new file, such as removing the sidebar section or anything. But, in order to get your file work you need to add the following comment right after the php opening tag. Here is the code.

<?php
/*
Single Post Template: [Custom Single]
Description: This part is optional, but helpful for describing the Post Template
*/
?>

The comment above will tell your WordPress theme to create a new custom template on the WYSIWYG editor in the post mode. You can rename the bold part with any name you want. Once everything is done without any problem, you should see the following option below the WYSIWYG editor.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

MOST-READ THIS WEEK