How to create a custom template file for single post pages.
It happen to me, I got the dreaded email from a BlogHer team member about a sponsored post that violated the agreement. Doh!! I am a violator, but not intentionally. I violated because I am an idiot basically.
You see, my baby only poops once every week or so and she cries and has the most raunchy farts you’ve ever smelled. She’s a very unhappy girl so her mommy and daddy are also unhappy, tired and quite brain dead.
I am four weeks postpartum and my pregnancy brain hasn’t cleared up, so when the Tune-In Bar came to my attention I was stoked to put it on my site and didn’t realize I’d have no means to remove the bar from my few sponsored post pages. Oops & crap!
Thankfully I did find a easy way to remove the Tune-In Bar code from only my sponsored post pages using a plugin, custom templates, some basic knowledge about templates and HTML knowledge.
I did this on my wordpress self hosted blog this week and you can too. Here is how:
1. First install and activate the Single Post Template Plugin here: http://www.nathanrice.net/plugins/single-post-template/
2. Next, create your own custom template file without the BlogHer Tune-In Bar code. Yeah, it is more complicated that I just made it sound in that sentence but I’ll walk you through it. It is easy, you can do it!
- First using an FTP program such as FileZilla locate and download the single.php file from your current template.
- Rename the single.php file, try something like altsingle.php and upload it to your server with all your other template files.
- Edit the alternative template file you just renamed & uploaded. I edited mine in the backend of my WordPress, self hosted blog by going to “appearance” and then “editor”.
- Add the following to the very top of your file:
Single Post Template: [Descriptive Template Name]
Description: This part is optional, but helpful for describing the Post Template
- I kept my single.php template file exactly the same but just replaced the <?php get_header(); ?> string with an entire copy and paste of the contents of my header.php file minus the BlogHer Tune-In Bar code
- Save the edited alternative template file. Then go to a post and test it out.
If you start a new post or edit an existing post you’ll now find a dropdown menu allowing you to select the template file you’d like to use.
Using this method the sky is the limit with your post pages. You can remove a portion of the side bar or the entire the side bar. Remove the header, footer, a BlogHer Ad code, add some custom tracking code… Whatever you can dream up can be done just by using custom templates.
This makes me quite happy as you can see. Probably because it’s like the only thing I am not a floundering idiot at these days. I can’t make my newborn baby happy right now but I can make custom templates and tell you how to make them too. That is a win I’ll be savoring until the next win cause a girl needs something to hold on to.
Enjoy your custom template making!
You might also consider reading this post: http://www.wpbeginner.com/wp-themes/create-custom-single-post-templates-for-specific-posts-or-sections-in-wordpress/ for further explanation. It is a similar post on the same concept. Or leave your questions in the comments section and I’ll try to help you out.