Sometimes you may want to customize the post template of a WordPress post. This can be the case for instance when you want to add something to the page the post is displayed on that should not appear on other post pages, or if you want to remove something, e.g. advertisement.
In the past, we have shown you how you can create custom tag pages and custom headers for categories which can be very helpful in this regard as well. These custom pages allow you for instance to add unique content to important pages to provide visitors with additional information.
The WordPress plugin Custom Post Template is ideal for our purpose. While it still requires you to add a new php file to your WordPress theme directory manually, you can afterwards use it comfortably from within the WordPress admin dashboard.
First thing that you need to do is install the Custom Post Template plugin on the WordPress site that you want to use it on. I have tested it on the latest available version, 3.4.1 at the time of writing, and it is working without issues there. Once you have installed and activated the plugin in the dashboard, fire up an ftp program and open the WordPress theme folder in it.
Now, the easiest way to create templates is to copy and rename the single.php file of your WordPress theme. You can name it any way you want, but I'd suggest you select a name that is easily identifiable.
Once done, edit the newly created file and add the following information at the very top of it before any other content:
Template Name Posts: noads
Replace the noads name with a name that you can identify the template by. You can now make modifications to the post template, like removing ads or adding advertisement to it. Save the file afterwards and repeat the process for as many template files as you want.
When you now open an existing post in the dashboard or write a new one, you will see a Post Template module on the page that you can use to switch from the default WordPress template to a newly created one.
I'd suggest you verify that everything is in order by previewing the post before you publish it on the site. This is especially important at the first time to make sure that everything has been configured correctly in the template file.Advertisement
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.