All posts on your WordPress site will be formatted using the single.php template. The single.php file is used when you click on the post title on the home page of the blog, and you see just the single post. This is efficient, but what if you have a Category of your website where you want the post page to look different, for example, a photo gallery that you want to take up the full page width with no sidebars? Here’s a bit of homework for you to make a custom single.php template for a particular Category:
- Put some content on your site if you don’t have any content. (Note: You can download andimport dummy content from http://wpcandy.com/articles/easier-theme-development-with-the-sample-post-collection.html. Simply, download and unzip the XML file and go to Tools > Import > WordPress and import this file into your site.)
- Take note of the Category ID # of the category for which you want to create a custom Single.php file. To get the ID #, mouse over the Category name in the Admin area and look in the browser footer.

- Make a back up copy of single.php, call this single-original.php.
- Open single.php in your HTML editor. Delete the contents of single.php and place the following code in it. Substitute the number 3 for the Category ID # you noted in step 2 above.
<?php $post = $wp_query->post; if ( in_category('3') ) { include(TEMPLATEPATH . '/single2.php'); } else { include(TEMPLATEPATH . '/single1.php'); } ?>What this code says: If the post is in Category 3, then use the single2.php template to display the post. If the post is not in Category 3, then display the post using single1.php.
- Open single-original.php in your HTML editor and choose File > Save As and call this file single1.php. Choose File > Save As again and call this file single2.php. You should now have four files: single.php, single1.php, single2.php, and single-original.php (we won’t actually use single-original.php — this is for backup purposes only).
- Open single2.php in your HTML editor. Make whatever changes you want to make to this file to have it be unique to the category you specified above.
- Upload single.php, single1.php and single2.php as well as style.css (if you made changes to it) to your theme’s folder.
- Refresh your web page and click on one of the post titles in the category for which you are using single2.php.










Pingback: Tweets that mention Creating a Custom Single.php template | WordPress Girl | WordPress Theme, Plugin, and Styling Advicee | Boulder, Colorado -- Topsy.com