Welcome to the ninth installment of my Wonderful WordPress Wednesday series.
NOTE: Although the main focus of this week’s tutorial is sponsored blog posts, there are many, many uses for what I’ll be sharing with y’all today so don’t run off just yet. After the tutorial I’ll share some other great uses for today’s lesson.
Anyone who has ever taken a sponsored post through any of the ‘paid to blog’ companies knows that they’re all full of various rules restricting how you can lay out your blog. Anyone who has taken sponsored posts for more than a few months has no doubt run into frustrations at what seems to be the usurping of your blog by these companies. Well, I’ve finally found a simple and elegant solution – separate templates for individual blog posts.
To see what I mean click over to my latest post at Gilroy Review about how columnist Cynthia Walker hates poor people. Scroll down and take a look at the entire layout of that post. Then click on the navigation to go to the post before it on Mary Jane Goods. Notice anything different? The ad placements are totally different because one is a sponsored post while the other is not. (BTW, if you’re reading this Google, the sponsored links are all nofollowed so don’t get your servers in a bunch).
All I had to do to accomplish those entirely different post layouts was tell my blog that a different author wrote each post. I use author because I’m the only person writing on these blogs and my blog themes don’t mention author names anyway. I could do the same thing with a specific tag or category as well. I only use author because it’s completely transparent on my blogs. Now, this did take a little set-up which is what I’m going to layout for y’all here in this post.
I learned how to do this, BTW, thanks to a great post by Justin Tadlock on his terrific Life, Blogging & WordPress blog. That post contains a lot of code because it covers so many options, and all of that code can be pretty intimidating to people who aren’t used to messing about ‘under the hood’ of their WordPress installation. So I’m going to stick to one simple system here. If you want to change templates based on something besides the author of the post then please visit Justin’s site and you should be able to follow along just fine after seeing how easy it is here.
How It’s Done-
Enough blathering. On to the tutorial itself…
First you’ll need to visit Appearance > Editor within your WordPress Admin and select your Single Post (single.php) file. Select the everything in the text box there (either drag your cursor over all of it or simply click in the box and hit CTRL-A) and then paste it into your favorite text editor. Personally I use EditPad, but Notepad works just as well in this case and is available on every Windows computer.
This is the basic template file that determines the layout of the single post pages on your blog. It’s probably already setup in an ‘advertiser friendly’ manner so you’re going to leave this copy alone.
Now return to your WordPress admin, go to Users > Add New and make a new user that you’ll only use for your sponsored posts (or whatever pots you want to use the old template for). By the way, if you want the author to display the same as your current account on your blog just include the same name in the Nickname box and select that name in the “Display name publicly as” drop down menu. Ok, once that user is made click on them to go to their edit page and look at the URL in your address bar. Roughly in the middle you should see something along the lines of
"?user_id=4". That number is the key to our next step. Return to your text editor program and save the file as
single-author-?.php, replacing the ? with the number you saw in the URL above. Pretty easy so far, right?
Okay, now you just need to open your FTP program and connect to your server. Navigate to
Your Blog > wp-content > themes > Your Theme and make a new folder or directory there called
single. Then upload your newly saved file to that folder/directory. It should end up looking something like my FTP directory to the right.
That was the hardest part, I promise. Now you just need to return to your WordPress admin area again and go to Appearance > Editor but this time select Theme Functions (functions.php). Each of these is going to look a little bit different depending on what theme you’re using, but you don’t need to worry about that. Just scroll down to the very bottom where you’ll see
?> and place your cursor on the blank line above that one. Then paste the following into the file and hit Update File-
Now just go back to your Single Post (single.php) file and make whatever changes you want to your single post layout – ad layouts, styles, backgrounds, etc – without having to worry about the opinions of the sponsored blog companies you work for. Just make sure to select that other (fictitious) author whenever you do a paid post and theirs will appear on a page that meets all of their requirements.
Personally, I also plan on using this when setting up a Daddy-Daughter blog with Zaira in the near future to give my posts a black & white color scheme and hers a pink & black scheme. This system would also be perfect for when you have guest bloggers and it can also be used to differentiate between categories or subjects on your blog rather easily. For example, if you have a weekly photo feature as many do, or host a blog carnival you could use an entirely different template for those posts. As I mentioned above, if you want to differentiate by category or tag just visit Justin Tadlock’s original post on the concept at his Life, Blogging & WordPress.
I’m sure there are plenty of other uses for this as well, so if you’ve got any ideas, please leave a comment and let me know! Or, if you have any questions or problems, just leave a note and, as always, I’l ldo my best to help.!
The Complete Wonderful WordPress Wednesdays Series-