How to create a Custom Single Post Template

Create a new template for single posts in just 2 minutes

I would like to start by saying how much I love my current WordPress theme. It’s the first premium theme that I bought and at the time it fulfilled all my needs.

However, over time I started to hate dislike the single page template because of the sidebar. So, today I decided to change the single post template to make it distraction-free by centering the content, removing the sidebar and adding spacing from both sides.

Before we get to the technical stuff, I highly recommend creating a Child theme first prior to any changes.

Are you ready for the coding? Okay, here we go:

Step 1. Open your theme folder and copy single.php  file, then rename it to something else like new-template.php THAT’S IT!

The new-template.php file added to the child theme folder.

That’s basically the fastest way to create a new template for single posts. Forget about plugins. or hiring a WordPress developer. It’s that easy to create a new post template. Now modifying, that’s a whole new thing.

Create New Single Post Template

If you’d like to create a new page template from scratch, you can do so by creating a new template-name.php file and add the following code:

That’s it, you now have a new template to choose from when creating a post/page:

Select your custom single post template

Category based Single Post Template

If you want to have different templates for posts under different categories, you can do so by adding the following inside the functions.php file:

This code will detect the category for the current post and show different single post template based on that.

Author based Single Post Template

If you want to have different templates for different authors, you can do so by using the same principles and adding this code to your functions.php file:

For more information about Post Templates check this WordPress.org documentation.

Add comment


We use cookies to provide an awesome experience on our website. By continuing to use this site, you agree to our tasty cookies.
🍪 Accept Cookies
Privacy Policy