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!
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.
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:
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.
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.